question: public final void sendTo ( DataOutput out ) throws IOException { finishWriting ( ) ; if ( this . chunks != null ) { for ( ByteBuffer bb : this . chunks ) { int bytesToWrite = bb . remaining ( ) ; if ( bytesToWrite > 0 ) { if ( bb . hasArray ( ) ) { out . write ( bb . array ( ) , bb . arrayOffset ( ) + bb . position ( ) , bytesToWrite ) ; bb . position ( bb . limit ( ) ) ; } else { byte [ ] bytes = new byte [ bytesToWrite ] ; bb . get ( bytes ) ; out . write ( bytes ) ; } this . size -= bytesToWrite ; } } } { ByteBuffer bb = this . buffer ; int bytesToWrite = bb . remaining ( ) ; if ( bytesToWrite > 0 ) { if ( bb . hasArray ( ) ) { out . write ( bb . array ( ) , bb . arrayOffset ( ) + bb . position ( ) , bytesToWrite ) ; bb . position ( bb . limit ( ) ) ; } else { byte [ ] bytes = new byte [ bytesToWrite ] ; bb . get ( bytes ) ; out . write ( bytes ) ; } this . size -= bytesToWrite ; } } }
target:  Write the contents of this stream to the specified stream. <p> Note this implementation is exactly the same as writeTo(OutputStream) but they do not both implement a common interface.