Here you can find the source of copyFile(File in, File out)
public static void copyFile(File in, File out) throws Exception
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { public static void copyFile(File in, File out) throws Exception { FileInputStream fis = new FileInputStream(in); FileOutputStream fos = new FileOutputStream(out); try {//from w ww . j a v a2 s. co m byte[] buf = new byte[1024]; int i = 0; while ((i = fis.read(buf)) != -1) { fos.write(buf, 0, i); } } catch (Exception e) { throw e; } finally { if (fis != null) fis.close(); if (fos != null) fos.close(); } } }