Java Utililty Methods Integer Create

List of utility methods to do Integer Create

Description

The list of methods to do Integer Create are organized into topic(s).

Method

int[]toInts(byte[] value, int offset, int num)
to Ints
int[] values = new int[num];
int idx = 0;
for (int i = offset; i < offset + (num * 4); i += 4) {
    values[idx++] = getInt(value, i);
return values;
int[]toInts(double[] arr)
This converts an array of doubles to integers (using type-casts, not rounding).
int[] ret = new int[arr.length];
for (int i = 0; i < arr.length; i++) {
    ret[i] = (int) arr[i];
return ret;
int[]toInts(int val)
Converts each byte in an integer to an integer, places them in MSB order.
int[] ints = new int[4];
for (int i = 0; i < 4; i++) {
    ints[3 - i] = 0xFF & val;
    val >>= 8;
return ints;
int[]toInts(Integer[] values)
to Ints
return toInts(values, DEFAULT_INT);
int[]toInts(long[] array)
to Ints
int[] ret = new int[array.length];
for (int e = 0; e < array.length; e++) {
    ret[e] = (int) array[e];
return ret;
int[]toInts(String intArray)
converts int values from string separated by " " (space) to an Array of integer
String[] s = intArray.split(" ");
int[] ia = new int[s.length];
for (int i = 0; i < ia.length; i++) {
    ia[i] = Integer.parseInt(s[i]);
return ia;
int[]toInts(String[] values)
to Ints
int[] result = new int[values.length];
for (int i = 0; i < result.length; i++) {
    result[i] = Integer.parseInt(values[i].trim());
return result;
int[]toIntsFromUBytes(byte[] byteArray)
Convert an array of "unsigned" bytes to an array of ints, where values from 128 to 255 are mapped from -128 to -1.
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;
StringtoIntStr(String floatStr)
to Int Str
if (floatStr == null || floatStr.length() < 1) {
    return "0";
int index = floatStr.indexOf(".");
if (index == -1)
    return floatStr;
if (index == 0)
    return "0";
...
StringtoIntString(Integer integer)
Formats the specified integer as string
if (integer == null) {
    return ZERO_STRING;
return integer.toString();