Here you can find the source of copyFile(File src, File dest)
public static boolean copyFile(File src, File dest)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class Main { public static boolean copyFile(File src, File dest) { boolean result = false; try {/*from w w w.j av a2s . com*/ FileInputStream fis = new FileInputStream(src); FileChannel sourcefc = fis.getChannel(); FileOutputStream fos = new FileOutputStream(dest); FileChannel targetfc = fos.getChannel(); if (sourcefc.transferTo(0, sourcefc.size(), targetfc) == sourcefc.size()) { result = true; } targetfc.close(); sourcefc.close(); fis.close(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return result; } }