简易实现图片下载

Posted timor88

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简易实现图片下载相关的知识,希望对你有一定的参考价值。

String str = null;
int size;
byte[] bytes = new byte[1024];

File file = new File("缓存目录");
URL url = new URL("图片链接");

BufferedInputStream bis = new BufferedInputStream(url.openStream());
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));

while((size = bis.read(bytes)) != -1){
bos.write(bytes,0,size);
}

bos.close();
bis.close();

以上是关于简易实现图片下载的主要内容,如果未能解决你的问题,请参考以下文章

flask实现文件简易服务器,可根据链接上传下载

flask实现文件简易服务器,可根据链接上传下载

简易Qt图片查看器

nodeJS实现简易爬虫

用tensorflow神经网络实现一个简易的图片分类器

html+css+javascript实现简易轮播图片