posts - 70,comments - 408,trackbacks - 0
这个方法接收2个参数,例如一个网络上的图片,和你要保存图片的地址.
public boolean initPhoto(String photoUrl,String filePath) {
  try {
   URL  url = null;
   try {
     url = new URL(photoUrl);
   } catch(Exception e) {
     System.out.println("URL ERROR");
     return false;
   }
   FilterInputStream in=(FilterInputStream) url.openStream();
   File fileOut=new File(filePath);
   FileOutputStream out=new FileOutputStream(fileOut);
   byte[] bytes=new byte[1024];
   int c;
   while((c=in.read(bytes))!=-1) {
    out.write(bytes,0,c);
   }
   in.close();
   out.close();
   return true;
  } catch(Exception e) {
   System.out.println("Error!");
   return false;
  }
 }
posted on 2006-08-07 11:00 我心依旧 阅读(3664) 评论(11)  编辑  收藏

FeedBack:
# re: 接收URL下载到本地的方法.
2007-03-29 12:57 | saus
<A href="http://www.saus.cn"">http://www.saus.cn" title="大屏幕拼接方案">大屏幕拼接方案网</A>提供专业的视频监控产品,大屏幕技术研究,大屏幕拼接方案咨询,下载;包括:DLP大屏幕拼接方案,CRT大屏幕拼接方案,LED大屏幕拼接方案,LCD液晶大屏幕拼接方案,PDP等离子大屏幕拼接方案.相关大屏幕背投设备有:DLP拼接数据单元/CRT拼接视频单元;大屏幕信号处理设备VGA|AV矩阵,长线驱动器和格式转换器;大屏幕显示设备背投一体机/等离子拼接单元.广泛应用于:DLP/液晶LCD/CRT/等离子PDP等大屏幕显示系统中.--<A href="http://www.saus.cn"">http://www.saus.cn" title="大屏幕拼接方案">大屏幕拼接方案网</A>  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2008-01-10 22:22 | 章春荣
我要看三味影院和暴风影院  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2008-06-17 15:14 | fanxinggui
我需要下载  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-01-03 20:23 | 外交王顺
祝大家新年快乐  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-01-03 20:24 | 外交王顺
祝大家新年快乐全家幸福‘  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-01-03 20:27 | 外交王顺
为什么狭窄不了

  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-05-26 23:11 | 沈海青
XVVBN  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-05-26 23:13 | 沈海青
HZXDS  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2009-08-11 10:37 | exv
<a href="http://www.exv.com.cn" title="大屏幕专业制造商">大屏幕</a>  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2010-05-31 17:03 | 李卓
FileOutputStream out=new FileOutputStream(fileOut);
这句为什么不执行啊,快急死了  回复  更多评论
  
# re: 接收URL下载到本地的方法.
2013-01-27 20:43 | 颜依林
FileOutputStream out=new FileOutputStream(fileOut);   回复  更多评论
  

只有注册用户登录后才能发表评论。


网站导航: