Eclipse bug:javax.imageio.IIOException:无法读取输入文件

par*_*uma 6 java eclipse javax.imageio

以下代码在BlueJ IDE中成功运行,但在Eclipse中未成功运行.

String path="images/pic1.jpg";

BufferedImage myPicture = null;
    try {
        myPicture = ImageIO.read(new File(path));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

我的图像路径在IDE中都是相同的.另外,我观察到*.class文件和图像文件的目录结构是相同的.

为什么只在eclipse中发生这种情况?

Kum*_*tra 0

尝试这个..

String path="d:\\images\\pic1.jpg";

BufferedImage myPicture = null;
    try {
        myPicture = ImageIO.read(new File(path));
    } catch (IOException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)