Java Utililty Methods Byte Array to Int

List of utility methods to do Byte Array to Int

Description

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

Method

intarr2int(byte[] arr, int start)
arrint
int low = arr[start] & 0xff;
int high = arr[start + 1] & 0xff;
return (int) (high << 8 | low);
intbufferToInt(byte[] ioBuffer)
buffer To Int
return (ioBuffer[0] << 24) + ((ioBuffer[1] & 255) << 16) + ((ioBuffer[2] & 255) << 8) + (ioBuffer[3] & 255);
intbyte2int(byte b[], int offset)
byteint
int val = 0;
int bits = 32;
int tval;
for (int i = 0; i < 4; i++) {
    bits -= 8;
    tval = b[offset + i];
    tval = tval < 0 ? 256 + tval : tval;
    val |= tval << bits;
...
intbyte2Int(byte bytes[])
byte Int
int num = bytes[0] & 0xFF;
num |= ((bytes[1] << 8) & 0xFF00);
num |= ((bytes[2] << 16) & 0xFF0000);
num |= ((bytes[3] << 24) & 0xFF000000);
return num;
intbyte2Int(byte[] b)
byte Int
int intValue = 0;
for (int i = 0; i < b.length; i++) {
    intValue += (b[i] & 0xFF) << (8 * (3 - i));
return intValue;
intbyte2int(final byte[] arr)
Convert int to byte[4]
int res = arr[3] & 0xff;
res = (res << 8) | (arr[2] & 0xff);
res = (res << 8) | (arr[1] & 0xff);
res = (res << 8) | (arr[0] & 0xff);
return res;
voidbyte2int(int[] output, byte[] input, int ioff, int len)
Byte2ints input (bytes) into output (int).
int i = 0;
for (int j = ioff; j < (ioff + len); j += 4) {
    output[i] = (input[j + 0] & 0xff) | ((input[j + 1] & 0xff) << 8) | ((input[j + 2] & 0xff) << 16)
            | ((input[j + 3] & 0xff) << 24);
    i++;
int[]byte2int2(byte[] src, int height, int width)
byteint
int dstLength = src.length;
int[] dst = new int[dstLength];
for (int i = 0; i < height * width; i++) {
    Byte b = new Byte(src[i]);
    dst[i] = b.intValue() & 0x000000ff;
return dst;
int[]byte2intarr(byte[] in)
byteintarr
int[] out = new int[in.length];
for (int i = 0; i < in.length; i++) {
    out[i] = in[i];
return out;
int[]byte2intArray(byte[] b)
byteint Array
int[] i = new int[b.length];
for (int x = 0; x < b.length; x++) {
    int t = b[x];
    if (t < 0) {
        t += 256;
    i[x] = t;
return i;