@ Nonnegative public static int transfer ( @ Nonnull final ByteBuffer aSrcBuffer , @ Nonnull final ByteBuffer aDstBuffer , final boolean bNeedsFlip ) { ValueEnforcer . notNull ( aSrcBuffer , "SourceBuffer" ) ; ValueEnforcer . notNull ( aDstBuffer , "DestinationBuffer" ) ; int nRead = 0 ; if ( bNeedsFlip ) { if ( aSrcBuffer . position ( ) > 0 ) { aSrcBuffer . flip ( ) ; nRead = _doTransfer ( aSrcBuffer , aDstBuffer ) ; if ( aSrcBuffer . hasRemaining ( ) ) aSrcBuffer . compact ( ) ; else aSrcBuffer . clear ( ) ; } } else { if ( aSrcBuffer . hasRemaining ( ) ) nRead = _doTransfer ( aSrcBuffer , aDstBuffer ) ; } return nRead ; }
Transfer as much as possible from source to dest buffer .