简易实现图片下载
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();
以上是关于简易实现图片下载的主要内容,如果未能解决你的问题,请参考以下文章