Here you can find the source of copyFile(final String from, final String to)
public static void copyFile(final String from, final String to) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**/*from ww w . ja v a 2 s .co m*/ * Copy file 'from' to file 'to' If not successful, exception is thrown */ public static void copyFile(final String from, final String to) throws IOException { byte[] daten = readFile(from); writeFile(to, daten); } public static byte[] readFile(final String fileNamePath) throws IOException { FileInputStream input = null; byte[] daten = null; try { input = new FileInputStream(fileNamePath); daten = new byte[input.available()]; input.read(daten); } finally { if (input != null) { input.close(); } } return daten; } public static void writeFile(final String fileNamePath, final byte[] daten) throws IOException { FileOutputStream output = null; try { output = new FileOutputStream(fileNamePath); output.write(daten); } finally { if (output != null) { output.close(); } } } }