Java Utililty Methods ByteBuffer to Long

List of utility methods to do ByteBuffer to Long

Description

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

Method

longreadLong(ByteBuffer buffer)
read Long
buffer.order(ByteOrder.LITTLE_ENDIAN);
long value = buffer.getLong();
buffer.order(ByteOrder.BIG_ENDIAN);
return value;
longreadLong(ByteBuffer buffer)
read Long
return buffer.getLong();
longreadLong(ByteBuffer in)
read Long
long integer = 0;
int mask = 0xff;
int shift = 0;
for (int i = 0; i < 8; i++) {
    integer |= (in.get() << shift) & mask;
    mask = mask << 8;
    shift += 8;
return integer;
longreadLong(ByteBuffer in, final int fitInBytes)
Read long which was written to fitInBytes bytes and increment position.
long tmpLength = 0;
for (int i = 0; i < fitInBytes; ++i) {
    tmpLength |= (in.get() & 0xffl) << (8l * i);
return tmpLength;
longreadLong(ByteBuffer logBuf)
Read a long from the log.
long ret = (logBuf.get() & 0xFFL) << 0;
ret += (logBuf.get() & 0xFFL) << 8;
ret += (logBuf.get() & 0xFFL) << 16;
ret += (logBuf.get() & 0xFFL) << 24;
ret += (logBuf.get() & 0xFFL) << 32;
ret += (logBuf.get() & 0xFFL) << 40;
ret += (logBuf.get() & 0xFFL) << 48;
ret += (logBuf.get() & 0xFFL) << 56;
...
longreadLong64ls(int size, ByteBuffer byteBuf)
read Longls
switch (size) {
case 0:
    return 0;
case 1:
    return byteBuf.get();
case 2:
    return byteBuf.getShort();
case 3:
...
long[]readLongArray(ByteBuffer bb)
read Long Array
long longs[] = null;
int size = bb.getInt();
if (size >= 0) {
    longs = new long[size];
    byte[] b = new byte[size * 8];
    bb.get(b);
    int l = 0;
    for (int i = 0; i < b.length;) {
...
longreadLongLE(ByteBuffer buf, int i)
read Long LE
assert buf.order() == ByteOrder.LITTLE_ENDIAN;
return buf.getLong(i);
intreadUB1(ByteBuffer buffer)
read UB
int ret = buffer.get() & 0xff;
return ret;
longreadUB4(ByteBuffer buffer)
read UB
long ret = (long) (buffer.get() & 0xff);
ret |= (long) (buffer.get() & 0xff) << 8;
ret |= (long) (buffer.get() & 0xff) << 16;
ret |= (long) (buffer.get() & 0xff) << 24;
return ret;