Here you can find the source of downloadFileFromInternet(String remoteUrl)
public static File downloadFileFromInternet(String remoteUrl) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.net.URL; public class Main { public static File downloadFileFromInternet(String remoteUrl) throws Exception { BufferedInputStream inputStream = null; BufferedOutputStream outputStream = null; try {/*www . j a v a 2s .c om*/ URL url = new URL(remoteUrl); File tempFile = File.createTempFile("temp", "zip"); inputStream = new BufferedInputStream(url.openStream()); outputStream = new BufferedOutputStream(new FileOutputStream(tempFile)); int read = 0; while ((read = inputStream.read()) != -1) { outputStream.write(read); } inputStream.close(); outputStream.flush(); outputStream.close(); return tempFile; } catch (Exception e) { throw e; } finally { try { inputStream.close(); outputStream.close(); } catch (Exception ex) { } } } }