两种方法一 写全路径:
try {
File f = new File("c:\\eclipse\\workspace\\...\\src\\bull.gif");
if (f.exists()) {
Image image = ImageIO.read(f);
} else
System.out.println("not find file!!");
} catch (IOException e) {
e.printStackTrace();
}
2、写工程路径
ry {
File f = new File("src\\bull.gif");
if (f.exists()) {
Image image = ImageIO.read(f);
} else
System.out.println("not find file!!");
} catch (IOException e) {
e.printStackTrace();
}
try {
File f = new File("c:\\eclipse\\workspace\\...\\src\\bull.gif");
if (f.exists()) {
Image image = ImageIO.read(f);
} else
System.out.println("not find file!!");
} catch (IOException e) {
e.printStackTrace();
}
2、写工程路径
ry {
File f = new File("src\\bull.gif");
if (f.exists()) {
Image image = ImageIO.read(f);
} else
System.out.println("not find file!!");
} catch (IOException e) {
e.printStackTrace();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货