六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 50|回复: 0

下载网络图片

[复制链接]

升级  50%

5

主题

5

主题

5

主题

童生

Rank: 1

积分
25
 楼主| 发表于 2013-1-15 01:54:54 | 显示全部楼层 |阅读模式
public  String  writeFile(String strUrl, String fileName) { String path="d:/webimg";URL url = null;try {url = new URL(strUrl);} catch (MalformedURLException e2) {e2.printStackTrace();}InputStream is = null;try {is = url.openStream();} catch (IOException e1) {path=null;e1.printStackTrace();}OutputStream os = null;File f = new File(path);f.mkdirs();try {path=path+"/" + fileName;os = new FileOutputStream(path);int bytesRead = 0;byte[] buffer = new byte[8192];while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {os.write(buffer, 0, bytesRead);}} catch (FileNotFoundException e) {e.printStackTrace();path=null;} catch (IOException e) {e.printStackTrace();path=null;}return path;}  
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表