Here you can find the source of copyFile(File src, File dst)
public static void copyFile(File src, File dst) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class Main { public static void copyFile(File src, File dst) throws IOException { long p = 0, dp, size; FileChannel in = null, out = null; try {/*www. java 2 s . c o m*/ if (!dst.exists()) dst.createNewFile(); in = new FileInputStream(src).getChannel(); out = new FileOutputStream(dst).getChannel(); size = in.size(); while ((dp = out.transferFrom(in, p, size)) > 0) { p += dp; } } finally { try { if (out != null) out.close(); } finally { if (in != null) in.close(); } } } }