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());