Here you can find the source of copy(File sourceFile, File destinationFile)
public static void copy(File sourceFile, File destinationFile) throws IOException
//package com.java2s; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; public class Main { public static void copy(File sourceFile, File destinationFile) throws IOException { FileReader reader = null; FileWriter writer = null; try {/* w w w. ja va 2 s. c o m*/ reader = new FileReader(sourceFile); writer = new FileWriter(destinationFile); int data = reader.read(); while (data != -1) { writer.write(data); data = reader.read(); } } finally { if (writer != null) { writer.close(); } if (reader != null) { reader.close(); } } } }