tang7526
3/12/2016 - 8:43 PM

download file from url

download file from url

public static void main(String[] args) {
	String url = "http://www.apache.org/dist/httpcomponents/httpclient/binary/httpcomponents-client-4.5-bin.zip";
	String FileNamePath ="E:\\test\\test.jar"; 
	getFile(url, FileNamePath);
}		

public void getFile(String url, String FileNamePath) {
	try{
		URL source = new URL(url);
		File destination = new File(FileNamePath);
		FileUtils.copyURLToFile(source, destination);
		System.out.println("File Downloaded!");
	}catch(IOException e){
		e.printStackTrace();
	}
}