Here you can find the source of copyFileFromFileToFile(File fromFile, File toFile)
public static void copyFileFromFileToFile(File fromFile, File toFile) throws IOException
//package com.java2s; //License from project: Apache License 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 copyFileFromFileToFile(File fromFile, File toFile) throws IOException { FileInputStream in = new FileInputStream(fromFile); FileOutputStream out = new FileOutputStream(toFile); copyFile(in, out);//ww w. ja v a 2s . c om in.close(); in = null; out.flush(); out.close(); out = null; } public static void copyFile(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[1024]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } } }