TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
一个多线程下载程序源码,下面是测试代码:
- import com.downfile.*;
- /*
- *请先配置好JDOM及downFile.jar
- */
- public class DownFileTest {
- public DownFileTest() {
- }
- public static void main(String[] args) {
- String urlFile; //网络地址
- int threadNum; //文件下载线程数
- String localAddress; //本地地址
- urlFile = "http://www.netbox.cn:88/download/nbsetup.EXE";
- //现在还只能够处理1到9个线程,后面的的版本再增加
- threadNum = 9;
- //注:路径的形式一定要写出下面的格式,特别的最好的路径称号不能缺
- localAddress = "d:\multiDownTest";
-
- DownFile downFile = new DownFile(urlFile, threadNum, localAddress);
- downFile.startDownFile();
-
- urlFile = "http://dl.360safe.com/setup.exe";
- DownFile downFile1 = new DownFile(urlFile, threadNum, localAddress);
- downFile1.startDownFile();
-
- urlFile = "http://down.sandai.net/Thunder5.6.8.329.exe";
- DownFile downFile2 = new DownFile(urlFile, threadNum, localAddress);
- downFile2.startDownFile();
- }
- }
复制代码
源码下载:http://file.javaxxz.com/2014/11/5/000000609.zip |
|