question: public final void writeTo ( SocketChannel sc , ByteBuffer buf ) throws IOException { if ( getLength ( ) > 0 ) { final int BUF_MAX = buf . capacity ( ) ; if ( this . part instanceof byte [ ] ) { final byte [ ] bytes = ( byte [ ] ) this . part ; int off = 0 ; int len = bytes . length ; buf . clear ( ) ; while ( len > 0 ) { int bytesThisTime = len ; if ( bytesThisTime > BUF_MAX ) { bytesThisTime = BUF_MAX ; } buf . put ( bytes , off , bytesThisTime ) ; len -= bytesThisTime ; off += bytesThisTime ; buf . flip ( ) ; while ( buf . remaining ( ) > 0 ) { sc . write ( buf ) ; } buf . clear ( ) ; } } else if ( this . part instanceof StoredObject ) { StoredObject c = ( StoredObject ) this . part ; ByteBuffer bb = c . createDirectByteBuffer ( ) ; if ( bb != null ) { while ( bb . remaining ( ) > 0 ) { sc . write ( bb ) ; } } else { int len = c . getDataSize ( ) ; long addr = c . getAddressForReadingData ( 0 , len ) ; buf . clear ( ) ; while ( len > 0 ) { int bytesThisTime = len ; if ( bytesThisTime > BUF_MAX ) { bytesThisTime = BUF_MAX ; } len -= bytesThisTime ; while ( bytesThisTime > 0 ) { buf . put ( AddressableMemoryManager . readByte ( addr ) ) ; addr ++ ; bytesThisTime -- ; } buf . flip ( ) ; while ( buf . remaining ( ) > 0 ) { sc . write ( buf ) ; } buf . clear ( ) ; } } } else { HeapDataOutputStream hdos = ( HeapDataOutputStream ) this . part ; hdos . sendTo ( sc , buf ) ; hdos . rewind ( ) ; } } }
target:  Write the contents of this part to the specified socket channel using the specified byte buffer. This is only called for parts that will not fit into the commBuffer so they need to be written directly to the socket. Precondition: buf contains nothing that needs to be sent