public static int copyWsByteBuffer ( WsByteBuffer src , WsByteBuffer dst , int amount ) { int amountCopied = amount ; int dstRemaining = dst . remaining ( ) ; int srcRemaining = src . remaining ( ) ; if ( amountCopied > dstRemaining ) amountCopied = dstRemaining ; if ( amountCopied > srcRemaining ) amountCopied = srcRemaining ; if ( amountCopied > 0 ) { int srcLimit = src . limit ( ) ; src . limit ( src . position ( ) + amountCopied ) ; dst . put ( src ) ; src . limit ( srcLimit ) ; } return amountCopied ; }
Copies up to amount bytes from src to dst . Returns the number of bytes actually copied .