Java Utililty Methods Byte Array to Long

List of utility methods to do Byte Array to Long

Description

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

Method

longbytesToLong(byte[] bytes, int off)
Constructs long from byte array.
return fromBytes(bytes, off, 8);
longbytesToLong(byte[] bytes, int off, boolean bigEndian)
bytes To Long
return bigEndian ? bytesToLongBE(bytes, off) : bytesToLongLE(bytes, off);
longbytesToLong(byte[] data)
bytes To Long
int offset = 0;
long a1 = data[offset + 3] & 0xFF;
long a2 = data[offset + 2] & 0xFF;
long a3 = data[offset + 1] & 0xFF;
long a4 = data[offset + 0] & 0xFF;
long res1 = (a1) + (a2 << 8) + (a3 << 16) + (a4 << 24);
offset += 4;
long b1 = data[offset + 3] & 0xFF;
...
longbytesToLong(byte[] data)
bytes To Long
long n = 0xffL & data[0];
for (int i = 1; i < 8; i++) {
    n = (n << 8) | (0xffL & data[i]);
return n;
LongbytesToLong(byte[] data)
bytes To Long
if (data.length > 8)
    throw new RuntimeException("array too long to convert to long");
long result = 0;
for (byte x : data)
    result = (result << 8) | (x & 0xff);
return result;
longbytesToLong(byte[] data, int offset)
bytes To Long
long num = 0;
for (int i = offset; i < offset + 8; i++) {
    num <<= 8;
    num |= (data[i] & 0xff);
return num;
longbytesToLong(byte[] inbytes, int shift)
bytes To Long
long result = 0;
for (int i = 0 + shift; i < 8 + shift; i++) {
    result = (result << 8) + (inbytes[i] & 0xff); 
return result;
longbytesToLong(byte[] longBytes)
bytes To Long
byte[] data = new byte[8];
System.arraycopy(longBytes, 0, data, 0, 8);
int mask = 0xff;
long temp = 0;
long res = 0;
for (int i = 0; i < 8; i++) {
    res <<= 8;
    temp = data[i] & mask;
...
longbytesToLong(byte[] p, int offset)
bytes To Long
return l(p[offset]) | (l(p[offset + 1]) << 8) | (l(p[offset + 2]) << 16) | (l(p[offset + 3]) << 24)
        | (l(p[offset + 4]) << 32) | (l(p[offset + 5]) << 40) | (l(p[offset + 6]) << 48)
        | (l(p[offset + 7]) << 56);
longbytesToLong(final byte[] b)
Convert a byte array to long.
return bytesToLong(b, 0);