首页 > 其他 > 详细

下载文件

时间:2016-11-25 11:34:41      阅读:190      评论:0      收藏:0      [点我收藏+]

/**

*图片下载

*url 图片地址

*path下载的路径(存放位置)

*index多图下载图片下标

*postfix 图片后缀

*/

private File downLoadImage(String url, String path, int index ,String postfix) throws Exception {
URL ul = new URL(url);
URLConnection uc = ul.openConnection();
File file = new File(path, "f" + index + postfix);
FileOutputStream fos = new FileOutputStream(file);
IOUtils.copy(uc.getInputStream(), fos);
IOUtils.close(uc);
IOUtils.closeQuietly(fos);
return file;
}

 

/**

*文件下载

*path下载的路径(存放位置)

*file  下载的文件

*/

private File downLoadFile(path,file) throws Exception {
File paramFile = new File(path, file);
OutputStreamWriter write = new OutputStreamWriter(new FileOutputStream(paramFile),"utf-8");
BufferedWriter bw = new BufferedWriter(write);
bw.write(mapper.writeValueAsString(command));
bw.flush();
bw.close();
return paramFile;
}

下载文件

原文:http://www.cnblogs.com/tanxd/p/6100742.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!