Here you can find the source of copyFile(final File fromFile, final File toFile)
public static void copyFile(final File fromFile, final File toFile) throws IOException
//package com.java2s; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void copyFile(final File fromFile, final File toFile) throws IOException { InputStream in = new FileInputStream(fromFile); OutputStream out = new FileOutputStream(toFile); byte[] buf = new byte[1024]; int len;// w w w .j a v a 2 s.co m while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); out.close(); } }