|
|
|
@ -48,7 +48,6 @@ public class MultiThreadDownloader {
|
|
|
|
|
long startPos = i * blockSize;
|
|
|
|
|
long endPos = (i == threadCount - 1) ? fileSize - 1 : (i + 1) * blockSize - 1;
|
|
|
|
|
String tempFile = tempDir + File.separator + "part_" + i;
|
|
|
|
|
|
|
|
|
|
executor.execute(new DownloadTask(i, startPos, endPos, tempFile, latch));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -70,7 +69,6 @@ public class MultiThreadDownloader {
|
|
|
|
|
mergeFiles(tempDir, saveDir + File.separator + fileName, threadCount);
|
|
|
|
|
// 删除临时文件
|
|
|
|
|
deleteDirectory(tempDir);
|
|
|
|
|
System.out.println("\n下载完成: " + saveDir + File.separator + fileName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|