Android Byte Array to Int Convert byteArrayToInt(byte[] b)

Here you can find the source of byteArrayToInt(byte[] b)

Description

byte Array To Int

Declaration

public static int byteArrayToInt(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {
    public static int byteArrayToInt(byte[] b) {

        if (b.length != 4)
            return 0;

        if (b.length != 4)
            return 0;
        int i = 0;
        int i1 = ((b[0] >= 0) ? b[0] : (b[0] + 256)) << 24;
        i = i + i1;/*from  www.jav  a2s.c o  m*/
        int i2 = ((b[1] >= 0) ? b[1] : (b[1] + 256)) << 16;
        i = i + i2;
        int i3 = ((b[2] >= 0) ? b[2] : (b[2] + 256)) << 8;
        i = i + i3;
        int i4 = (b[3] >= 0) ? b[3] : (b[3] + 256);
        i = i + i4;

        return i;
    }
}

Related

  1. toInts(byte... bytes)
  2. byteArrayToInt(byte[] b)
  3. bytes2int(byte[] data)
  4. byte2int(byte[] b)
  5. byteArray2Int(byte[] bs)
  6. toIntegerArray(byte[] input, int offset, int len)
  7. toIntegerArray(byte[] input, int offset, int len, int[] output, int outputOffset)
  8. toInt(byte[] bytes)
  9. toInteger(byte[] input)