Here you can find the source of copyFiles(File originalFile, File destinationFile)
public static void copyFiles(File originalFile, File destinationFile) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.*; import java.nio.channels.Channels; import java.nio.channels.FileChannel; import java.nio.channels.ReadableByteChannel; public class Main { public static void copyFiles(File originalFile, File destinationFile) throws FileNotFoundException, IOException { FileInputStream fis = new FileInputStream(originalFile); FileOutputStream fos = new FileOutputStream(destinationFile); FileChannel inCh = fis.getChannel(); FileChannel outCh = fos.getChannel(); outCh.transferFrom(inCh, 0, inCh.size()); fis.close();/* w w w . j a va2s . c o m*/ fos.close(); inCh.close(); outCh.close(); } public static void copyFiles(InputStream is, FileOutputStream fos) throws IOException { ReadableByteChannel inCh = Channels.newChannel(is); FileChannel outCh = fos.getChannel(); outCh.transferFrom(inCh, 0, Integer.MAX_VALUE); is.close(); fos.close(); inCh.close(); outCh.close(); } }