Here you can find the source of copy(File source, File dest)
public static void copy(File source, File dest) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; public class Main { public static void copy(File source, File dest) throws IOException { FileChannel in = null, out = null; try {//from ww w . ja va 2 s. co m in = new FileInputStream(source).getChannel(); out = new FileOutputStream(dest).getChannel(); long size = in.size(); MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size); out.write(buf); } finally { if (in != null) in.close(); if (out != null) out.close(); } } }