Here you can find the source of copyFile(String urlPath, String outFile)
public static Boolean copyFile(String urlPath, String outFile)
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.net.URL; import java.net.URLConnection; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; public class Main { public static Boolean copyFile(String urlPath, String outFile) { return copyFile(urlPath, outFile, false); }//from ww w. j av a 2 s. c om public static Boolean copyFile(String urlPath, String outFile, boolean force) { if (!force && new File(outFile).exists()) { return false; } try { URL url = new URL(urlPath); URLConnection con = url.openConnection(); Files.copy(con.getInputStream(), Paths.get(outFile), StandardCopyOption.REPLACE_EXISTING); return true; } catch (IOException ex) { throw new UncheckedIOException(ex); } } public static URLConnection openConnection(String urlPath) { try { URL url = new URL(urlPath); return url.openConnection(); } catch (IOException ex) { throw new UncheckedIOException(ex); } } }