Here you can find the source of copyFile(File in, File out)
public static boolean copyFile(File in, File out) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static boolean copyFile(File in, File out) throws Exception { try {// w ww . j a va 2 s . c om FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } fis.close(); fos.close(); return true; } catch (IOException ie) { ie.printStackTrace(); return false; } } public static boolean copyFile(String infile, String outfile) throws Exception { try { File in = new File(infile); File out = new File(outfile); return copyFile(in, out); } catch (IOException ie) { ie.printStackTrace(); return false; } } }