package jsoup;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.apache.commons.io.FileUtils;

public class Test {

public static void main(String[] args) throws MalformedURLException, IOException {
Map<Integer, String> map = new HashMap<Integer,String>();

String path = “http://files.eduuu.com/img/2014/12/04/170859_548024abcf1bf.png”;
String destFile = “d://”+UUID.randomUUID()+”.png”;
FileUtils.copyURLToFile(new URL(path), new File(destFile));
/*OutputStream os = new FileOutputStream(new File(destFile));
byte[] b = new byte[1024];
try {
InputStream is = new URL(path).openStream();
while (is.read(b) != -1) {
os.write(b);
}
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
*/

}

}

版权声明:本文为poilk原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/poilk/p/6433680.html