rendered paste bodypackage download;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.util.LinkedList;import java.util.List;import java.util.Queue;import java.util.concurrent.Executor;import java.util.concurrent.Executors;public class Downloader { private static final int numberOfDownloads = 5; Queue<String> downloads = new LinkedList<String>(); public static String outputDirectory = "."; public Downloader(String outputDirectory) { Downloader.outputDirectory = outputDirectory; add("URL HERE"); add("URL HERE"); add("URL HERE"); add("URL HERE"); add("URL HERE"); } private void add(String url) { this.downloads.add(url); } public void execute() { Executor executor = Executors.newFixedThreadPool (Downloader.numberOfDownloads); final List<Download> downloads = new LinkedList<Download>(); for (String download: this.downloads) { Download d = new Download(download); executor.execute(d); downloads.add(d); } Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { for (Download d: downloads) { d.shutDown(); } } }); } /** * @param args */ public static void main(String[] args) { Downloader d = new Downloader(args[0]); d.execute(); } private class Download implements Runnable { private String url; private static final String command = "wget -t5 -c -q -np -E -r -k -p -nd --directory-prefix="; private Process proc; public Download(String url) { this.url = url; } @Override public void run() { System.out.println("downloading " + this.url); Runtime rt = Runtime.getRuntime(); try { this.proc = rt.exec(Download.command + outputDirectory + " " + this.url); InputStream stderr = proc.getErrorStream(); InputStreamReader errorReader = new InputStreamReader(stderr); BufferedReader br = new BufferedReader(errorReader);// String line = null;// while ( (line = br.readLine()) != null) {// System.out.println(line);// } try { proc.waitFor(); } catch (InterruptedException e) { e.printStackTrace(); } } catch (IOException e) { e.printStackTrace(); } } public void shutDown() { if (this.proc != null) { this.proc.destroy(); } } } }