parent
7a060be84a
commit
d0cef1fe82
|
@ -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<Image> {
|
||||
|
@ -18,9 +20,9 @@ public class PlantImageDeserializer extends JsonDeserializer<Image> {
|
|||
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());
|
||||
|
|
Loading…
Reference in New Issue