Here you can find the source of copyFile(File in, File out)
public static final void copyFile(File in, File out)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static final void copyFile(File in, File out) { FileInputStream fis = null; FileOutputStream fos = null; try {//w ww .j a va 2 s . c o m fis = new FileInputStream(in); fos = new FileOutputStream(out); byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } } catch (IOException ie) { throw new RuntimeException(ie); } finally { if (null != fis) { try { fis.close(); } catch (IOException e) { fis = null; throw new RuntimeException(e); } } if (null != fos) { try { fos.close(); } catch (IOException e) { fos = null; throw new RuntimeException(e); } } } } public static final void copyFile(String infile, String outfile) { File in = new File(infile); File out = new File(outfile); copyFile(in, out); } }