Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void channelCopy( ReadableByteChannel src, WriteableByteChannel dest ){
- ByteBuffer buffer = ByteBuffer.allocateDirect( 16 * 1024 );
- while( src.read(buffer) != -1 ){
- //Prepare the buffer to be drained
- buffer.flip();
- while(buffer.hasRemaining()){
- dest.write(buffer);
- }
- //Make the buffer empty, ready for filling.
- buffer.clear();
- }
- }
Add Comment
Please, Sign In to add comment