Here you can find the source of copyFile(File source, File destination)
public static boolean copyFile(File source, File destination)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.channels.FileChannel; public class Main { public static boolean copyFile(File source, File destination) { FileInputStream inputStream = null; FileOutputStream outputStream = null; FileChannel fcin = null;/*from www . j a v a 2 s . co m*/ FileChannel fcout = null; try { inputStream = new FileInputStream(source); outputStream = new FileOutputStream(destination); fcin = inputStream.getChannel(); fcout = outputStream.getChannel(); long size = fcin.size(); fcin.transferTo(0L, size, fcout); } catch (Exception e) { e.printStackTrace(); return false; } finally { try { if (fcout != null) { fcout.close(); } } catch (Exception ex) { ex.printStackTrace(); } try { if (fcin != null) { fcin.close(); } } catch (Exception ex) { ex.printStackTrace(); } try { if (outputStream != null) { outputStream.close(); } } catch (Exception ex) { ex.printStackTrace(); } try { if (inputStream != null) { inputStream.close(); } } catch (Exception ex) { ex.printStackTrace(); } } return true; } }