public static long copy ( FileInputStream in , FileOutputStream out ) throws IOException { FileChannel source = null ; FileChannel destination = null ; try { source = in . getChannel ( ) ; destination = out . getChannel ( ) ; return source . transferTo ( 0 , source . size ( ) , destination ) ; } finally { CloseableUtils . close ( source ) ; CloseableUtils . close ( destination ) ; } }
Copy the file using streams .