java四行代码实现图片下载

如下:

InputStream in = new URL("http://www.updown/thumbnail.jpg).openStream();

Path temp = Paths.get("temp.png");
Files.copy(in,temp,StandardCopyOption.REPLACE_EXISTING);
File file = temp.toFile();
System.out.println(file.getAbsolutePath());

posted @ 2019-02-23 11:45  凉城  阅读(876)  评论(0编辑  收藏  举报