日期:2014-05-20 浏览次数:20953 次
URL url = new URL(urls);
URLConnection conn = url.openConnection();
conn.connect();
System.out.println(urls + " 长度:" + conn.getContentLength() / 1024 + "KB");
InputStream fis = conn.getInputStream();
long a = System.currentTimeMillis();
FileOutputStream out = new FileOutputStream(path);
byte buf[] = new byte[10240];
int n;
while ((n = fis.read(buf)) != -1) {
out.write(buf, 0, n);
}
fis.close();
out.close();
long b = System.currentTimeMillis();
System.out.println("[+]: 下载费时:"+ String.valueOf(b-a) + "毫秒");