Java Byte Array to Int bytes2IntArray(byte[] bytes)

Here you can find the source of bytes2IntArray(byte[] bytes)

Description

bytes Int Array

License

Open Source License

Declaration

public static int[] bytes2IntArray(byte[] bytes) 

Method Source Code

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

public class Main {
    public static int[] bytes2IntArray(byte[] bytes) {
        if (bytes == null || bytes.length < 4) {
            return new int[0];
        }//from ww w. j  a va 2 s . c  o m
        int[] array = new int[bytes.length / 4];
        int byteIndex = 0;
        int arrayIndex = 0;
        while (byteIndex < bytes.length) {
            int v = bytes[byteIndex++] & 0xff;
            v <<= 8;
            v |= (bytes[byteIndex++] & 0xff);
            v <<= 8;
            v |= (bytes[byteIndex++] & 0xff);
            v <<= 8;
            v |= (bytes[byteIndex++] & 0xff);
            array[arrayIndex++] = v;
        }
        return array;
    }
}

Related

  1. bytes2int(byte[] src)
  2. bytes2Int(byte[] src, int start)
  3. Bytes2Int16(byte[] sour, int offset)
  4. Bytes2Int32(byte[] sour, int offset)
  5. Bytes2Int64(byte[] sour, int offset)
  6. bytes2Integer(byte[] byteVal)
  7. bytes2LengthToIntLowOrder(byte[] intBytes)
  8. bytes2ToInt(byte[] inputValues)
  9. Bytes2Uint32(byte[] sour, int offset)