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

long[]toIntegerArray(String text, String delimiter)
split a text into array of integers
if (text == null || text.length() == 0) {
    return new long[0];
String[] textArray = text.split(delimiter);
long[] arr = new long[textArray.length];
for (int i = 0; i < arr.length; i++) {
    try {
        arr[i] = Long.parseLong(textArray[i]);
...
Integer[]toIntegerArray(String... values)
to Integer Array
if (values == null) {
    return new Integer[0];
Integer[] casted = new Integer[values.length];
for (int i = 0; i < casted.length; i++) {
    casted[i] = Integer.parseInt(values[i]);
return casted;
...
IntegertoIntegerByObject(Object obj)
to Integer By Object
try {
    return Integer.valueOf(toStringByObject(obj, true));
} catch (Exception e) {
    return 0;
IntegertoIntegerFromObj(Object obj)
Tenta transformar um obj em inteiro, caso nao consiga retorna null
try {
    return obj != null ? new Integer(obj.toString()) : null;
} catch (Exception e) {
return null;
IntegertoIntegerObject(boolean bool)

Converts a boolean to an Integer using the convention that zero is false.

 BooleanUtils.toIntegerObject(true)  = new Integer(1) BooleanUtils.toIntegerObject(false) = new Integer(0) 
return (bool ? INTEGER_ONE : INTEGER_ZERO);
IntegertoIntegerObject(Boolean bool, Integer trueValue, Integer falseValue, Integer nullValue)

Converts a Boolean to an Integer specifying the conversion values.

 BooleanUtils.toIntegerObject(Boolean.TRUE, new Integer(1), new Integer(0), new Integer(2))  = new Integer(1) BooleanUtils.toIntegerObject(Boolean.FALSE, new Integer(1), new Integer(0), new Integer(2)) = new Integer(0) BooleanUtils.toIntegerObject(null, new Integer(1), new Integer(0), new Integer(2))          = new Integer(2) 
if (bool == null) {
    return nullValue;
return bool.booleanValue() ? trueValue : falseValue;
IntegertoIntegerOrNull(String s)
to Integer Or Null
return s == null ? null : Integer.valueOf(s);
Integer[]toIntegers(String[] values)
to Integers
return toIntegers(values, null);
inttoIntegerValue(byte... bytes)
to Integer Value
return toIntegerValue(bytes, 0, bytes.length);
inttoIntegerValue(String value)
to Integer Value
try {
    return Float.valueOf(value).intValue();
} catch (NumberFormatException e) {
    e.printStackTrace();
finally {
return 0;
...