图片读取 怎么根据一个url读取图片,然后成为一个BufferedImage对象比如这个是读取文件的BufferedImage image = ImageIO.read(imageFile);那么怎么读取url,请指点一下,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public String saveToFile(String destUrl, String pathName) { FileOutputStream fos = null; BufferedInputStream bis = null; HttpURLConnection httpUrl = null; URL url = null; String fullPath = null; byte[] buf = new byte[BUFFER_SIZE]; int size = 0; try { url = new URL(destUrl); httpUrl = (HttpURLConnection) url.openConnection(); httpUrl.connect(); bis = new BufferedInputStream(httpUrl.getInputStream()); fullPath = getFullPath(pathName,this.fileFormat); fos = new FileOutputStream(fullPath); while ( (size = bis.read(buf)) != -1) { fos.write(buf, 0, size); } fos.flush(); } catch(IOException e) { } catch(ClassCastException e) { } finally { try { fos.close(); bis.close(); httpUrl.disconnect(); } catch(IOException e) { } catch(NullPointerException e) { } } return getImageName(fullPath); } 其实只要这一句BufferedImage image = ImageIO.read(url);先前没看api,后悔啊, 对于当前线程的几点疑惑(生产者消费者) 请问有没有多图片上传的插件,带预览图的那种? SSH的事务异常处理是这样理解吗? J2EE 1.5或者1.4 中文版API hibernate 3.2 长文本保存 乱码,短文件存储正常 在使用struts的html标签时,能不能实现联动菜单---100分 急!!!!!!!! 怎么读不到Properties文件属性的值呢 hibernate 问题 WebSphere中如何控制用户必须通过身份认证才可以获取数据库连接? cmp bean的错误 Jboss下载的时候的提示 谁知道如何能够实例化一个泛型list
FileOutputStream fos = null;
BufferedInputStream bis = null;
HttpURLConnection httpUrl = null;
URL url = null;
String fullPath = null;
byte[] buf = new byte[BUFFER_SIZE];
int size = 0;
try {
url = new URL(destUrl);
httpUrl = (HttpURLConnection) url.openConnection();
httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream());
fullPath = getFullPath(pathName,this.fileFormat);
fos = new FileOutputStream(fullPath); while ( (size = bis.read(buf)) != -1) {
fos.write(buf, 0, size);
}
fos.flush();
}
catch(IOException e) {
}
catch(ClassCastException e) {
}
finally {
try {
fos.close();
bis.close();
httpUrl.disconnect();
}
catch(IOException e) {
}
catch(NullPointerException e) {
}
}
return getImageName(fullPath);
}