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) + "毫秒");1:怎样得到 每秒下载速度 ?
2:n 是每次读取的字节数吗?
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) + "毫秒");1:怎样得到 每秒下载速度 ?
2:n 是每次读取的字节数吗?
解决方案 »
- 有关java的ftp关于rest命令的
- ireport高手请出来吧,搞不出来,小弟确实不想混了,严重打击我信心
- java编译器是由java实现的是什么意思
- JTextArea() help.......
- 请问在internalFrame中如何实现窗口的层叠,垂直和水平排列?
- ResultSet rs=stmt.executeQuery("select * from T_BASE where QDDM='"+DM+"' and RecordName=SJ");
- 希望各位都能进看看 (收集JAVA异常类)
- 考scjp最好用什莫书??前辈请指教
- 菜鸟问题,版本不对?
- java实现高精度计时,比如精确到小数点后9位小数
- 事件响应的大问题
- 如此简单的问题,马上给分
楼主【cooc123】截止到2008-06-28 11:16:33的历史汇总数据(不包括此帖):
发帖数:113 发帖分:1450
结贴数:34 结贴分:700
未结数:79 未结分:750
结贴率:30.09 % 结分率:48.28 %
楼主该结一些帖子了