diff --git a/src/main/java/ch/zhaw/gartenverwaltung/json/PlantImageDeserializer.java b/src/main/java/ch/zhaw/gartenverwaltung/json/PlantImageDeserializer.java index e5611fc..f22cb35 100644 --- a/src/main/java/ch/zhaw/gartenverwaltung/json/PlantImageDeserializer.java +++ b/src/main/java/ch/zhaw/gartenverwaltung/json/PlantImageDeserializer.java @@ -6,9 +6,11 @@ import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.JsonDeserializer; import javafx.scene.image.Image; +import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.net.URISyntaxException; import java.net.URL; public class PlantImageDeserializer extends JsonDeserializer { @@ -18,9 +20,9 @@ public class PlantImageDeserializer extends JsonDeserializer { Image result = null; URL imageUrl = PlantDatabase.class.getResource(String.format("images/%s", parser.getText())); if (imageUrl != null) { - try (InputStream is = new FileInputStream(imageUrl.getFile())) { + try (InputStream is = new FileInputStream(new File(imageUrl.toURI()))) { result = new Image(is); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException | URISyntaxException e) { // TODO: Log e.printStackTrace(); System.err.printf("Cannot find Image \"%s\"\n", imageUrl.getFile());