question: private static void doCopyFile ( File srcFile , File destFile , boolean preserveFileDate ) throws IOException { if ( destFile . exists ( ) && destFile . isDirectory ( ) ) { throw new IOException ( "Destination '" + destFile + "' exists but is a directory" ) ; } FileInputStream fis = null ; FileOutputStream fos = null ; FileChannel input = null ; FileChannel output = null ; try { fis = new FileInputStream ( srcFile ) ; fos = new FileOutputStream ( destFile ) ; input = fis . getChannel ( ) ; output = fos . getChannel ( ) ; long size = input . size ( ) ; long pos = 0 ; long count = 0 ; while ( pos < size ) { count = size - pos > FILE_COPY_BUFFER_SIZE ? FILE_COPY_BUFFER_SIZE : size - pos ; pos += output . transferFrom ( input , pos , count ) ; } } finally { IOUtils . closeQuietly ( output ) ; IOUtils . closeQuietly ( fos ) ; IOUtils . closeQuietly ( input ) ; IOUtils . closeQuietly ( fis ) ; } if ( srcFile . length ( ) != destFile . length ( ) ) { throw new IOException ( "Failed to copy full contents from '" + srcFile + "' to '" + destFile + "'" ) ; } if ( preserveFileDate ) { destFile . setLastModified ( srcFile . lastModified ( ) ) ; } }
target:  Internal copy file method.