I have a code which download file from URL.
I have a two parameters that calculated all time for downloading :
Long start = System.nanoTime();
// downloading...
Long end = System.nanoTime();
I need to measure estimated remaining time to end of downloading. How i can do that?
A 100Mbps (megabits per second) fibre connection will give you a download speed of 12.5MBps (megabytes per second). A 1GB file is equal to 1024MB, so it should take 81.9 seconds to download the file.
If you're calculating the download time for another file, it's important to remember that 300Mbps stands for 300 Megabits per second (where 8 Megabits are equal to one MegaByte). For this reason, if you're downloading a 300MB (300 MegaByte) file, it will take you 8 seconds to do this and not one second.
It was simply, sorry 4 your time.
For future searchers :
When you start downloading save timestamp :
Long startTime = System.nanoTime();
to calculate average remaining speed :
Long elapsedTime = System.nanoTime() - startTime;
Long allTimeForDownloading = (elapsedTime * allBytes / downloadedBytes);
Long remainingTime = allTimeForDownloading - elapsedTime;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With