Android Utililty Methods Byte Array to Int Convert

List of utility methods to do Byte Array to Int Convert

Description

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

Method

intbyteArrayToInt(byte[] b)
Converts a 4 byte array to an int.
int value = 0;
for (int i = 0; i < 4; i++) {
    int shift = (4 - 1 - i) * 8;
    value += (b[i] & 0xFF) << shift;
return value;
intbyteArrayToInt(byte[] bytes)
byte Array To Int
int value = 0;
for (int i = 0; i < 4; i++) {
    int shift = (4 - 1 - i) * 8;
    value += (bytes[i] & 0x000000FF) << shift;
return value;
intbytes2Int(byte[] data)
bytes Int
if (data.length == 1) {
    return (int) data[0];
} else {
    int mask = 0xff;
    int temp = 0;
    int n = 0;
    for (int i = 0; i < 4; i++) {
        n <<= 8;
...
intbytesToInt(byte[] b)
bytes To Int
int n = (int) ((((b[3] & 0xff) << 24) | ((b[2] & 0xff) << 16)
        | ((b[1] & 0xff) << 8) | ((b[0] & 0xff) << 0)));
return n;
intbytesToInt(byte[] bytes)
bytes To Int
return bytes[3] & 0xFF | (bytes[2] & 0xFF) << 8
        | (bytes[1] & 0xFF) << 16 | (bytes[0] & 0xFF) << 24;
intbytesToInt(byte[] bytes)
Converts a byte[] of unsigned bytes in big-endian order to an int.
int i = 0;
i |= (bytes[0] & 0xFF) << 24;
i |= (bytes[1] & 0xFF) << 16;
i |= (bytes[2] & 0xFF) << 8;
i |= (bytes[3] & 0xFF);
return i;
intbytesToInt(byte[] in)
bytes To Int
return ByteBuffer.wrap(in).getInt(); 
intbytesLE2int(byte[] b, int off)
bytes L Eint
return ((b[off + 3] & 0xff) << 24) | ((b[off + 2] & 0xff) << 16)
        | ((b[off + 1] & 0xff) << 8) | (b[off] & 0xff);
int[]bytesLE2ints(byte[] b)
bytes L Eints
if (b == null)
    return null;
if ((b.length & 0x3) != 0)
    throw new IllegalArgumentException("byte[" + b.length + "]");
int[] val = new int[b.length >> 2];
for (int i = 0; i < val.length; i++)
    val[i] = bytesLE2int(b, i << 2);
return val;
...
intbyteToUint(byte b)
Converts the byte into an unsigned int.
return (b < 0 ? 256 + b : b);