Here you can find the source of copy(File src, File dest)
@SuppressWarnings("resource") public static void copy(File src, File dest) throws IOException
//package com.java2s; //License from project: Open Source 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 { @SuppressWarnings("resource") public static void copy(File src, File dest) throws IOException { if (!src.exists()) return; if (!dest.exists()) dest.mkdir();/*from w w w. j a v a2 s. c o m*/ for (File f : src.listFiles()) { File target = new File(dest, f.getName()); if (f.isDirectory()) copy(f, target); if (f.isFile()) { FileChannel ic = new FileInputStream(f).getChannel(); FileChannel oc = new FileOutputStream(target).getChannel(); try { ic.transferTo(0, ic.size(), oc); } finally { ic.close(); oc.close(); } } } } }