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; import java.io.*; public class Main { public static void copyFile(File source, File dest) throws IOException { if (!dest.exists()) { dest.createNewFile();/*from w w w . j a v a2 s . c o m*/ } InputStream in = null; OutputStream out = null; try { in = new FileInputStream(source); out = new FileOutputStream(dest); // Transfer bytes from in to out byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } } finally { if (in != null) { in.close(); } if (out != null) { out.close(); } } } }