implement ProgressMonitor.java
This commit is contained in:
@@ -16,7 +16,6 @@ public class ProgressMonitor implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// TODO:
|
|
||||||
// Repeatedly check chunk progress until all chunks are completed.
|
// Repeatedly check chunk progress until all chunks are completed.
|
||||||
// In each loop:
|
// In each loop:
|
||||||
// 1. Read the downloaded size from every chunk
|
// 1. Read the downloaded size from every chunk
|
||||||
@@ -45,7 +44,7 @@ public class ProgressMonitor implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.printf(
|
System.out.printf(
|
||||||
"Progress for %s: %.1f/%.1f MB (%.2f%%), completed chunks: %d/%d%n",
|
"\nProgress for %s: %.1f/%.1f MB (%.2f%%), completed chunks: %d/%d%n%n",
|
||||||
fileName,
|
fileName,
|
||||||
totalDownloadedMB,
|
totalDownloadedMB,
|
||||||
(double) totalSizeMB,
|
(double) totalSizeMB,
|
||||||
@@ -54,9 +53,11 @@ public class ProgressMonitor implements Runnable {
|
|||||||
chunks.size()
|
chunks.size()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// TODO:
|
|
||||||
// If all chunks are completed, print a final message and exit the loop
|
// If all chunks are completed, print a final message and exit the loop
|
||||||
|
if(completedChunks == chunks.size()){
|
||||||
|
System.out.println(fileName + " downloaded completely.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(monitorDelayMs);
|
Thread.sleep(monitorDelayMs);
|
||||||
|
|||||||
Reference in New Issue
Block a user