This is my first post. Excuse me if I'm making an obvious mistake.
BufferedImage img = null;
File file = new File("com/game/assets/badlogic.jpg");
try {
img = ImageIO.read(file);
} catch (IOException e) {
e.printStackTrace();
}
This is my code and it can't read my image input file for some reason. This is the error message:
javax.imageio.IIOException: Can't read input file!
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1308)
at com.engine.Main.run(Main.java:41)
at java.base/java.lang.Thread.run(Thread.java:844)
at com.engine.Main.start(Main.java:32)
at com.game.GameManager.main(GameManager.java:51)
I have no clue what am I doing wrong. Anyways Thank You, kind Strangers.
I got it to work!
BufferedImage img = null;
try {
img = ImageIO.read(new FileInputStream("/Users/earmalys/Desktop/InteliJ projects/mantengine/src/com/game/assets/badlogic.jpg"));
} catch (IOException e) {
e.printStackTrace();
}
But the file path is very exact. Is there anyway I can get around this?