Java Integer Create toIntsFromUBytes(byte[] byteArray)

Here you can find the source of toIntsFromUBytes(byte[] byteArray)

Description

Convert an array of "unsigned" bytes to an array of ints, where values from 128 to 255 are mapped from -128 to -1.

License

Open Source License

Parameter

Parameter Description
byteArray Array of "unsigned" bytes to be converted.

Return

Array of ints.

Declaration

public static int[] toIntsFromUBytes(byte[] byteArray) 

Method Source Code

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

public class Main {
    /**//from   w  ww.  j  a  va2 s  .c o m
     * Convert an array of "unsigned" bytes to an array of ints, where values from 128 to 255 are mapped from -128 to -1.
     * 
     * @param byteArray
     *            Array of "unsigned" bytes to be converted.
     * @return Array of ints.
     */
    public static int[] toIntsFromUBytes(byte[] byteArray) {
        if (byteArray == null)
            throw new NullPointerException();
        int[] intArray = new int[byteArray.length];
        for (int i = 0; i < byteArray.length; i++)
            intArray[i] = byteArray[i] & 0xFF;
        return intArray;
    }
}

Related

  1. toInts(int val)
  2. toInts(Integer[] values)
  3. toInts(long[] array)
  4. toInts(String intArray)
  5. toInts(String[] values)
  6. toIntStr(String floatStr)
  7. toIntString(Integer integer)
  8. toIntString(Object object)
  9. toIntUnsigned(short x)