读取服务器端图片问题
想做读取服务器端硬盘里存储的图片
File f=new File("E:/123.jpg");
BufferedImage image = null;
try {
image = ImageIO.read(f);------>出错
} catch (IOException e) {
e.printStackTrace();
}
return image;
报错如下:
javax.imageio.IIOException: Can't read input file!
at javax.imageio.ImageIO.read(Unknown Source)
at cn.com.jtv.service.ShowImageServiceImpl.firstLoadImage(ShowImageServiceImpl.java:47)
而测试代码
public static void main(String[] args){
File f=new File("E:/123.jpg");
BufferedImage image = null;
try {
image = ImageIO.read(f);
Raster ra = image.getData();
Rectangle rect = ra.getBounds();
System.out.println(ra.getWidth());
System.out.println(ra.getHeight());
System.out.println(image.getClass());
//data.put("image",image);
} catch (IOException e) {
e.printStackTrace();
}
}
结果:
100
100
class java.awt.image.BufferedImage
是因为web服务没法读取指定盘符的文件么?
我想获得指定盘下面的图片(图片不在webApps文件夹中),如何能得到?
[解决办法]
到处发帖啊,呵呵