我想加载一个图像作为我的平台游戏的一部分,但它不能缝找到图像,我把它放入默认包,这是类无法加载图像 - 图像未找到
public BufferedImage loadImage() {
try {
BufferedImage img = ImageIO.read(new File("level.jpg"));
System.out.println("Level Found!");
return img;
} catch (IOException e) {
System.out.println("Level Missing!");
return null;
}
}
你可以粘贴你的Stacktrace吗? – Prasad
文件是否正确部署在您的类路径中? –
尝试提供绝对路径.... –