Android Byte Array to Int Convert byteArray2Int(byte[] bs)

Here you can find the source of byteArray2Int(byte[] bs)

Description

byte Array Int

License

Open Source License

Declaration

public static int byteArray2Int(byte[] bs) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static final int BYTE_MASK = 0xff;

    public static int byteArray2Int(byte[] bs) {
        if (bs.length != 4)
            throw new IllegalArgumentException();
        int res = 0;
        res |= (bs[0] & BYTE_MASK) << 24;
        res |= (bs[1] & BYTE_MASK) << 16;
        res |= (bs[2] & BYTE_MASK) << 8;
        res |= (bs[3] & BYTE_MASK);/*  w  ww .jav a 2s  .  c o m*/
        return res;
    }
}

Related

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