1.字节流
将网络图片的url预览地址,变为本地a.png图片
try(InputStream ins = new URL(url).openStream(); FileOutputStream fos = new FileOutputStream("d://data/a.png");) {
File file2 = FileUtil.file(url);
byte[] b = new byte[1024];
int length;
while ((length = ins.read(b)) > 0) {
fos.write(b, 0, length);
}
} catch (IOException e) {
e.printStackTrace();
}
结果: