Java Integer Create toIntA(byte[] data)

Here you can find the source of toIntA(byte[] data)

Description

to Int A

License

Open Source License

Declaration

public static int[] toIntA(byte[] data) 

Method Source Code

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

public class Main {
    public static int[] toIntA(byte[] data) {
        if (data == null || data.length % 4 != 0)
            return null;
        // ----------
        int[] ints = new int[data.length / 4];
        for (int i = 0; i < ints.length; i++)
            ints[i] = toInt(new byte[] { data[(i * 4)], data[(i * 4) + 1],
                    data[(i * 4) + 2], data[(i * 4) + 3], });
        return ints;
    }//from   w w  w  .j  av a2 s . c  o m

    public static int toInt(byte[] data) {
        if (data == null || data.length != 4)
            return 0x0;
        // ----------
        return (int) ( // NOTE: type cast not necessary for int
        (0xff & data[0]) << 24 | (0xff & data[1]) << 16
                | (0xff & data[2]) << 8 | (0xff & data[3]) << 0);
    }
}

Related

  1. toInt24(final int value)
  2. toInt32(int[] data, int startIndex)
  3. toInt32(long x)
  4. toInt32(Object prmIntObject)
  5. toInt4Trim(String value, int _default)
  6. toIntArr(String s, String split)
  7. toIntArray(boolean[] array)
  8. toIntArray(boolean[] selectedValues)
  9. toIntArray(byte[] byteArray)