Error: Unhandled exception type IOException.
File imgLoc = new File("player.png");
BufferedImage img = ImageIO.read(imgLoc);
How do I get a bufferedImage from a file location?
Error: Unhandled exception type IOException.
File imgLoc = new File("player.png");
BufferedImage img = ImageIO.read(imgLoc);
How do I get a bufferedImage from a file location?
Does the file exist ? Are you by chance reading from an unexpected directory ?
Try File.exists() and/or File.canRead()
The cause of your problem is best determined by examining a stacktrace for the exception.
As a temporary measure, replace those two lines with the following:
File imgLoc = new File("player.png");
BufferedImage img;
try {
img = ImageIO.read(imgLoc);
} catch (IOException ex) {
System.err.println(ex.getMessage());
ex.printStackTrace();
throw ex;
}
to send some diagnostics to standard error. Run the modified app and post the resulting output.
Possible causes include: