Java Utililty Methods Byte Array Big Endian

List of utility methods to do Byte Array Big Endian

Description

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

Method

longbytesBE2long(byte[] b, int off)
bytes B Elong
return ((b[off] & 0xffL) << 56) | ((b[off + 1] & 0xffL) << 48) | ((b[off + 2] & 0xffL) << 40)
        | ((b[off + 3] & 0xffL) << 32) | ((b[off + 4] & 0xffL) << 24) | ((b[off + 5] & 0xffL) << 16)
        | ((b[off + 6] & 0xffL) << 8) | (b[off + 7] & 0xffL);
floatBytesBEToFloat(final byte[] value)
Bytes BE To Float
return Float.intBitsToFloat(BytesBEToInt(value));
intBytesBEToInt(final byte[] buf)
Bytes BE To Int
int val = 0x0;
for (int i = 0; i < buf.length; i++) {
    val += ((int) buf[i] & 0xFF) << ((3 - i) * 8);
return val;
charbytesHighFirstToChar(byte[] bytes, int start)
bytes High First To Char
char c = (char) (((bytes[start] & 0xFF) << 8) | (bytes[start + 1] & 0xFF));
return c;
floatbytesHighFirstToFloat(byte[] bytes, int start)
bytes High First To Float
int l = bytesHighFirstToInt(bytes, start);
return Float.intBitsToFloat(l);
intbytesHighFirstToInt(byte[] bytes, int start)
bytes High First To Int
int num = bytes[start + 3] & 0xFF;
num |= ((bytes[start + 2] << 8) & 0xFF00);
num |= ((bytes[start + 1] << 16) & 0xFF0000);
num |= ((bytes[start] << 24) & 0xFF000000);
return num;