Java Utililty Methods ByteBuffer Shift

List of utility methods to do ByteBuffer Shift

Description

The list of methods to do ByteBuffer Shift are organized into topic(s).

Method

ByteBufferleftShift(final ByteBuffer buffer, int shift)
left Shift
final BigInteger bigInt = new BigInteger(buffer.array());
final byte[] shiftedBytes = bigInt.shiftLeft(shift).and(allOnes((buffer.remaining()) * BYTE_LENGTH))
        .toByteArray();
final int resultLength = buffer.capacity();
final int sourceOffset = resultLength >= shiftedBytes.length ? 0 : 1;
final int destinationOffset = resultLength - shiftedBytes.length > 0 ? resultLength - shiftedBytes.length
        : 0;
Arrays.fill(buffer.array(), (byte) 0);
...
booleanshift(ByteBuffer buffer, int distance)
shift
if (distance <= 0) {
    throw new IllegalArgumentException("Negative distance: " + distance);
int limit = buffer.limit();
int position = buffer.position() + distance;
if (position > limit) {
    buffer.position(limit);
    return false;
...