网络图片下载并保存本地
2014-12-23 18:16
459 查看
<pre name="code" class="java">@Test public void getFile(){ String fileUrl="http://static.zuchecdn.com/images/order/hg.jpg"; Integer fileId=1; String path="d:/csms/"+fileId+".jpg"; System.out.print(path); try{ URL url=new URL(fileUrl); HttpURLConnection connection=(HttpURLConnection) url.openConnection(); connection.connect(); InputStream is=connection.getInputStream(); OutputStream os=new FileOutputStream(path); BufferedOutputStream buffer=new BufferedOutputStream(os); byte[] b=new byte[1024]; int len=0; while((len=is.read(b))>0){ buffer.write(b,0,len); } buffer.flush(); os.close(); is.close(); }catch (Exception e) { e.printStackTrace(); } }
相关文章推荐
- Android 下载网络图片保存到本地
- Android 下载网络图片保存到本地
- Android下载网络图片并保存在本地相册
- Ruby1.9.3-下载网络图片至本地,并按编号保存。
- cocos2dx下载网络图片保存在本地
- 根据网络图片下载保存到新路径(包括本地)
- [转]java 下载网络上的图片并保存到本地目录
- java 下载网络上的图片并保存到本地目录
- java 下载网络上的图片并保存到本地目录
- 【Java】下载网络上的图片并保存到本地目录
- Android 下载网络图片保存到本地
- java 下载网络上的图片并保存到本地目录
- 从网络上进行下载图片,并保存到本地
- Android异步从网络下载图片并且缓存图片到本地的demo
- [工具库]JFileDownloader工具类——多线程下载网络文件,并保存在本地
- ios 从网络下载图片,保存,并用imageview从保存中显示
- 下载图片--网络图片下载。(读取网络文件,填充到本地文件。)
- 通过Java HTTP连接将网络图片下载到本地
- ConnectStream下载网络图片转成MemorySteam下载到本地
- 通过Java HTTP连接将网络图片下载到本地