public static void appendFile(File sourceFile, File destinationFile) {
        ValidationUtils.assertNotNull(destinationFile, "destFile");
        ValidationUtils.assertNotNull(sourceFile, "sourceFile");
        if (!FileLocks.lock(sourceFile)) {
            throw new FileLockException("Fail to lock " + sourceFile);
        }
        if (!FileLocks.lock(destinationFile)) {
            throw new FileLockException("Fail to lock " + destinationFile);
        }

        FileChannel in = null;
        FileChannel out = null;
        try {
            in = new FileInputStream(sourceFile).getChannel();
            out = new FileOutputStream(destinationFile, true).getChannel();
            final long size = in.size();
            // In some Windows platforms, copying large files fail due to insufficient system resources.
            // Limit copy size to 32 MB in each transfer
            final long count = 32 * MB;
            long position = 0;

            while (position < size) {
                position += in.transferTo(position, count, out);
            }
        } catch (IOException e) {
            throw new SdkClientException("Unable to append file " + sourceFile.getAbsolutePath()
                    + "to destination file " + destinationFile.getAbsolutePath() + "\n" + e.getMessage(), e);
        } finally {
            closeQuietly(out, LOG);
            closeQuietly(in, LOG);
            FileLocks.unlock(sourceFile);
            FileLocks.unlock(destinationFile);
            try {
                if (!sourceFile.delete()) {
                    LOG.warn("Failed to delete file " + sourceFile.getAbsolutePath());
                }
            } catch (SecurityException exception) {
                LOG.warn("Security manager denied delete access to file " + sourceFile.getAbsolutePath());
            }
        }
    }
public static void appendFile ( File sourceFile , File destinationFile ) { ValidationUtils . assertNotNull ( destinationFile , "destFile" ) ; ValidationUtils . assertNotNull ( sourceFile , "sourceFile" ) ; if ( ! FileLocks . lock ( sourceFile ) ) { throw new FileLockException ( "Fail to lock " + sourceFile ) ; } if ( ! FileLocks . lock ( destinationFile ) ) { throw new FileLockException ( "Fail to lock " + destinationFile ) ; } FileChannel in = null ; FileChannel out = null ; try { in = new FileInputStream ( sourceFile ) . getChannel ( ) ; out = new FileOutputStream ( destinationFile , true ) . getChannel ( ) ; final long size = in . size ( ) ; final long count = 32 * MB ; long position = 0 ; while ( position < size ) { position += in . transferTo ( position , count , out ) ; } } catch ( IOException e ) { throw new SdkClientException ( "Unable to append file " + sourceFile . getAbsolutePath ( ) + "to destination file " + destinationFile . getAbsolutePath ( ) + "\n" + e . getMessage ( ) , e ) ; } finally { closeQuietly ( out , LOG ) ; closeQuietly ( in , LOG ) ; FileLocks . unlock ( sourceFile ) ; FileLocks . unlock ( destinationFile ) ; try { if ( ! sourceFile . delete ( ) ) { LOG . warn ( "Failed to delete file " + sourceFile . getAbsolutePath ( ) ) ; } } catch ( SecurityException exception ) { LOG . warn ( "Security manager denied delete access to file " + sourceFile . getAbsolutePath ( ) ) ; } } }
Append the data in sourceFile to destinationFile.

Note that the sourceFile is deleted after appending the data.

@param sourceFile
The file that is to be appended.
@param destinationFile
The file to append to.