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

inttoInt(final byte[] pBytes)
Converts a byte array to an int.
return (pBytes[0] & 0xff) << 24 | (pBytes[1] & 0xff) << 16 | (pBytes[2] & 0xff) << 8 | (pBytes[3] & 0xff);
inttoInt(final Double value)
to Int
return Integer.parseInt("" + ((long) Math.floor(value)));
int[]toInt(final double[] a, final int len)
to Int
final int[] b = new int[len];
for (int i = 0; i < len; i++)
    b[i] = (int) a[i];
return b;
inttoInt(final int r, final int g, final int b)
to Int
return DCM_ALPHA_MASK | (r << 16) | (g << 8) | b;
inttoInt(final long a)
to Int
if (a != (int) a) {
    return a < 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE;
return (int) a;
inttoInt(final long n)
to Int
if (n > Integer.MAX_VALUE)
    throw new ArithmeticException(n + " = n > Integer.MAX_VALUE = " + Integer.MAX_VALUE);
if (n < Integer.MIN_VALUE)
    throw new ArithmeticException(n + " = n > Integer.MIN_VALUE = " + Integer.MIN_VALUE);
return (int) n;
inttoInt(final Object obj)
to Int
try {
    if (obj instanceof String) {
        return Integer.valueOf((String) obj).intValue();
    } else if (obj instanceof Number) {
        return ((Number) obj).intValue();
    } else {
        throw new IllegalArgumentException("Could not convert value to integer: " + obj);
} catch (Exception e) {
    throw new IllegalArgumentException("Could not convert value to number: " + obj, e);
IntegertoInt(final Object valueRep)
to Int
return Integer.parseInt(String.valueOf(valueRep));
inttoInt(final String s)
to Int
final int number;
switch (s.charAt(s.length() - 1)) {
case 'K':
case 'k':
    number = Integer.parseInt(s.substring(0, s.length() - 1).trim()) * 1024;
    break;
case 'M':
case 'm':
...
inttoInt(final String str, final int alt)
A safe way to parse an integer elsewhere in the code.
try {
    return Integer.parseInt(str);
} catch (NumberFormatException nfe) {
    System.out.println("--- Stack Trace ---");
    nfe.printStackTrace();
    return alt;