Here you can find the source of copy(File from, File to)
public static void copy(File from, File to) throws MalformedURLException, IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; public class Main { public static void copy(File from, File to) throws MalformedURLException, IOException { copy(from.toURI().toURL(), to);/*from ww w . j a v a 2 s .com*/ } public static void copy(URL from, File to) throws MalformedURLException, IOException { if (!to.exists()) { ReadableByteChannel rbc; rbc = Channels.newChannel(from.openStream()); FileOutputStream fos = new FileOutputStream(to); fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); } } }