Here you can find the source of copyFile(File source, File target)
private static void copyFile(File source, File target) throws IOException
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static void copyFile(File source, File target) throws IOException { try (InputStream in = new FileInputStream(source); OutputStream out = new FileOutputStream(target)) { byte[] buf = new byte[1024]; int length; while ((length = in.read(buf)) > 0) { out.write(buf, 0, length); }/*from w w w . ja va 2 s . c om*/ } } }