Package: org.conscrypt
BufferUtils
public final class BufferUtils
Utility methods for dealing with arrays of ByteBuffers.
Public Methods
checkNotNull
public static void checkNotNull(ByteBuffer[] buffers)
remaining
public static long remaining(ByteBuffer[] buffers)
Returns the total number of bytes remaining in the buffer array.
consume
public static void consume(ByteBuffer[] sourceBuffers, int toConsume)
Marks
toConsume
bytes of data as consumed from the buffer array.
| Throws |
| IllegalArgumentException |
if there are fewer than
toConsume
bytes remaining |
getBufferLargerThan
public static ByteBuffer getBufferLargerThan(ByteBuffer[] buffers, int minSize)
Looks for a buffer in the buffer array which EITHER is larger than
minSize
AND
has no preceding non-empty buffers OR is the only non-empty buffer in the array.
copyNoConsume
public static ByteBuffer copyNoConsume(ByteBuffer[] buffers, ByteBuffer destination, int maxAmount)
Copies up to
maxAmount
bytes from a buffer array to
destination
.
The copied data is
not
marked as consumed from the source buffers, on the
assumption the copy will be passed to some method which will consume between 0 and
maxAmount
bytes which can then be reflected in the source array using the
consume()
method.