Here you can find the source of copyFile(File aSource, File aDest)
public static File copyFile(File aSource, File aDest) throws IOException
//package com.java2s; import java.io.*; public class Main { /**//from ww w.j a v a2 s .c om * Copies a file from one location to another. */ public static File copyFile(File aSource, File aDest) throws IOException { // Get input stream, output file and output stream FileInputStream fis = new FileInputStream(aSource); File out = aDest.isDirectory() ? new File(aDest, aSource.getName()) : aDest; FileOutputStream fos = new FileOutputStream(out); // Iterate over read/write until all bytes written byte[] buf = new byte[8192]; for (int i = fis.read(buf); i != -1; i = fis.read(buf)) fos.write(buf, 0, i); // Close in/out streams and return out file fis.close(); fos.close(); return out; } }