List of utility methods to do ByteBuffer Split
List | split(ByteBuffer buffer, byte tag) Split buffer by tag List<ByteBuffer> list = new ArrayList<ByteBuffer>(); byte[] srcArray = buffer.array(); trim(buffer, tag); for (int i = 0, start = 0, end = 0; i < buffer.limit(); i++) { if (srcArray[i] != tag) { end = i; } else { int len = end - start + 1; ... |
ByteBuffer | split(ByteBuffer buffer, int position) split int bytesLength = position - buffer.position(); byte[] bytes = new byte[bytesLength]; buffer.get(bytes); return ByteBuffer.wrap(bytes); |
ByteBuffer[] | split(ByteBuffer src, int unitSize) split int limit = src.limit(); if (unitSize >= limit) { return null; int size = (int) (Math.ceil((double) src.limit() / (double) unitSize)); ByteBuffer[] ret = new ByteBuffer[size]; int srcIndex = 0; for (int i = 0; i < size; i++) { ... |
void | splitLongToBuffers(ByteBuffer buffer, ByteBuffer buffer1, long iValue) Split long value into two byte buffer. int remaining = buffer.remaining(); int i; for (i = 0; i < remaining; ++i) { buffer.put((byte) (iValue >> SIZE_OF_BYTE_IN_BITS * (SIZE_OF_LONG - i - 1))); for (int j = 0; j < SIZE_OF_LONG - remaining; ++j) { buffer1.put((byte) (iValue >> SIZE_OF_BYTE_IN_BITS * (SIZE_OF_LONG - i - j - 1))); |
void | splitShortToBuffers(ByteBuffer buffer, ByteBuffer buffer1, short iValue) Split short value into two byte buffer. buffer.put((byte) (MASK & (iValue >>> SIZE_OF_BYTE_IN_BITS))); buffer1.put((byte) (MASK & iValue)); |