Here you can find the source of copyFile(File sourceFile, File destFile)
public static void copyFile(File sourceFile, File destFile) 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; public class Main { public static void copyFile(File sourceFile, File destFile) throws IOException { FileInputStream inStream = new FileInputStream(sourceFile); try {/*w w w. j a v a2 s .c om*/ FileOutputStream outStream = new FileOutputStream(destFile); try { inStream.getChannel().transferTo(0, sourceFile.length(), outStream.getChannel()); } finally { outStream.close(); } } finally { inStream.close(); } } }