Here you can find the source of copyFile(File from, File to)
private static void copyFile(File from, File to)
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { private static void copyFile(File from, File to) { if (!from.exists()) { return; }/*from w w w . jav a2s.co m*/ FileInputStream in = null; FileOutputStream out = null; try { in = new FileInputStream(from); out = new FileOutputStream(to); byte bt[] = new byte[1024]; int c; while ((c = in.read(bt)) > 0) { out.write(bt, 0, c); } } catch (Exception e) { e.printStackTrace(); } finally { try { if (in != null) { in.close(); } if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } } }