private void copyFile( final JGitPathImpl source,
final JGitPathImpl target,
final CopyOption... options ) {
final InputStream in = newInputStream( source, convert( options ) );
final SeekableByteChannel out = newByteChannel( target, new HashSet<OpenOption>() {{
add( StandardOpenOption.TRUNCATE_EXISTING );
for ( final CopyOption _option : options ) {
if ( _option instanceof OpenOption ) {
add( (OpenOption) _option );
}
}
}} );
try {
int count;
byte[] buffer = new byte[ 8192 ];
while ( ( count = in.read( buffer ) ) > 0 ) {
out.write( ByteBuffer.wrap( buffer, 0, count ) );
}
} catch ( Exception e ) {
throw new IOException( e );
} finally {
try {
out.close();
} catch ( java.io.IOException e ) {
throw new IOException( e );
} finally {
try {
in.close();