这是我用来加载名为“boat.png”的图像的代码
@Override
public void paint(Graphics g) {
BufferedImage img = null;
try {
img = ImageIO.read(new File("boat.png"));
} catch (IOException e) {
System.out.println("Can't load the image");
}
}
这两行会产生错误
BufferedImage img = null;
img = ImageIO.read(new File("boat.png"));
虽然我已经包括
import java.io.*;
import java.awt.*;
请帮我找出错误!