Here you can find the source of copyFile(File source, File dest)
public static void copyFile(File source, File dest) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.channels.FileChannel; public class Main { public static void copyFile(File source, File dest) throws IOException { if (!source.exists()) return; if (!dest.exists()) { dest.getParentFile().mkdirs(); dest.createNewFile();//from ww w . ja va 2 s . c o m } FileChannel srcChannel = new FileInputStream(source).getChannel(); FileChannel dstChannel = new FileOutputStream(dest).getChannel(); dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); srcChannel.close(); dstChannel.close(); } }