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);
I debugged it and reaches the next line of code after the download is completed.
How can I get the number of bytes that transferFrom()
wrote during it's writing a file, to write it to a log or to the console?
Something like this
while (len = fch.getWriteBytes()) {
System.out.println(len + " bytes : " + (len/total)*100 + "%");
}
Sorry for incomplete question.