Here you can find the source of copyFile(File src, File dest)
@SuppressWarnings("resource") public static void copyFile(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 copyFile(File src, File dest) throws IOException { FileChannel inChannel = new FileInputStream(src).getChannel(); FileChannel outChannel = new FileOutputStream(dest).getChannel(); int maxCount = (64 * 1024 * 1024) - (32 * 1024); long size = inChannel.size(); long position = 0; while (position < size) { position += inChannel.transferTo(position, maxCount, outChannel); }/* w ww . j a v a 2s .c o m*/ if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); dest.setLastModified(src.lastModified()); } }