Here you can find the source of copyFile(File src, File dst)
static boolean copyFile(File src, File dst)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; public class Main { static boolean copyFile(File src, File dst) { byte[] buf = new byte[65536]; int read; try {/* w w w.ja va 2 s . c o m*/ FileInputStream fis = new FileInputStream(src); FileOutputStream fos = new FileOutputStream(dst); while ((read = fis.read(buf)) > 0) fos.write(buf, 0, read); silentClose(fos); silentClose(fis); return true; } catch (Throwable t) { System.err.println( "Could NOT copy \"" + src.getAbsolutePath() + "\" to \"" + dst.getAbsolutePath() + "\":"); t.printStackTrace(); return false; } } static void silentClose(Object o) { try { o.getClass().getMethod("close").invoke(o); } catch (Throwable t) { } } }