Here you can find the source of copyFile(File sourceFile, File destFile)
public static void copyFile(File sourceFile, File destFile)
//package com.java2s; import java.io.*; import java.nio.channels.FileChannel; public class Main { public static void copyFile(File sourceFile, File destFile) { try {// ww w.j ava 2 s . com if (!destFile.exists()) { destFile.createNewFile(); } FileChannel source = null; FileChannel destination = null; try { source = new FileInputStream(sourceFile).getChannel(); destination = new FileOutputStream(destFile).getChannel(); destination.transferFrom(source, 0, source.size()); } finally { close(source); close(destination); } } catch (Exception e) { e.printStackTrace(); } } public static void close(Closeable closeable) { try { closeable.close(); } catch (Exception e) { // Ignore! } } }