Here you can find the source of download(String link, File destFile)
public static boolean download(String link, File destFile)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; import java.util.logging.Level; import java.util.logging.Logger; public class Main { public static boolean download(String link, File destFile) { return download(link, destFile, false); }//ww w . j a v a2s . com public static boolean download(String link, File destFile, boolean append) { try { final URL url = new URL(link); try (ReadableByteChannel channel = Channels.newChannel(url.openStream()); FileChannel fileChannel = new FileOutputStream(destFile, append).getChannel()) { fileChannel.transferFrom(channel, append ? (fileChannel.size()) : 0, Long.MAX_VALUE); } return true; } catch (IOException ex) { Logger.getLogger("Util").log(Level.WARNING, "Util.download", ex); return false; } } }