Here you can find the source of copyFile(File from, File to)
public static void copyFile(File from, File to)
//package com.java2s; //License from project: Open Source License import java.io.*; import java.util.Scanner; public class Main { public static void copyFile(File from, File to) { try {/*ww w . j a v a 2 s. c om*/ Scanner fromScanner = new Scanner(new FileInputStream(from)); PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(to))); while (fromScanner.hasNextByte()) { out.print(fromScanner.nextByte()); } out.close(); fromScanner.close(); } catch (IOException e) { e.printStackTrace(); } } }