Here you can find the source of copy(final File source, final File dest)
public static void copy(final File source, final 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 { public static void copy(final File source, final File dest) throws IOException { final FileChannel inChannel = new FileInputStream(source).getChannel(); final FileChannel outChannel = new FileOutputStream(dest).getChannel(); try {// w w w. ja va 2s . c om // magic number for Windows, 64Mb - 32Kb) final int maxCount = (64 * 1024 * 1024) - (32 * 1024); final long size = inChannel.size(); long position = 0; while (position < size) position += inChannel.transferTo(position, maxCount, outChannel); } finally { if (inChannel != null) inChannel.close(); if (outChannel != null) outChannel.close(); } } }