[英]How to get number of bytes that FileChannel.transferFrom wrote during it's writting
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 + "%");
}
对不起,问题不完整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.