【发布时间】:2013-11-04 05:01:35
【问题描述】:
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
ReadableByteChannel rbc = Channels.newChannel(conn.getInputStream());
FileOutputStream fos = new FileOutputStream(fileName);
FileChannel fch = fos.getChannel();
fch.transferFrom(rbc, 0, Long.MAX_VALUE);
我调试了一下,下载完成后到了下一行代码。
如何获取transferFrom() 在写入文件、写入日志或控制台期间写入的字节数?
类似的东西
while (len = fch.getWriteBytes()) {
System.out.println(len + " bytes : " + (len/total)*100 + "%");
}
抱歉,问题不完整。
【问题讨论】: