Https://zhidao.baidu.com/question/1446055057527183940.html
Import Java.io.BufferedInputStream;
Import Java.io.File;
Import java.io.FileNotFoundException;
Import Java.io.FileOutputStream;
Import java.io.IOException;
Import java.net.HttpURLConnection;
Import Java.net.URL;
Import Java.net.URLDecoder;
Import Java.util.Vector;
Import java.util.concurrent.Callable;
Import Java.util.concurrent.ExecutorService;
Import java.util.concurrent.Executors;
Import Java.util.concurrent.Future; /** * This example uses synchronous downloads based on JDK httpurlconnection, which are downloaded sequentially * If you download multiple tasks at the same time, you can use multithreading * @author ak1ng * */public class Demo1 {PU Blic static void Main (string[] args) {//download list vector<string> downloadlist = new Vector<string>
;();
Add Download Address Downloadlist.add (");
Downloadlist.add (");
Download (downloadlist); /** * Download/static void download (Vector<string> downloadlist) {//thread pool Exec
Utorservice pool = null;
HttpURLConnection connection = null;
Cycle download try {for (int i = 0; i < downloadlist.size (); i++) {pool = Executors.newcachedthreadpo
OL ();
Final String url = downloadlist.get (i);
String filename = GetFileName (Downloadlist.get (i));
SYSTEM.OUT.PRINTLN ("Downloading the first" + (i+1) + "files, Address:" + URL); future