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(String str)
to Int
if (str != null && !str.equals("")) {
    int value1;
    try {
        value1 = Integer.parseInt(str);
    } catch (Exception var3) {
        var3.printStackTrace();
        value1 = 0;
    return value1;
} else {
    return 0;
inttoInt(String str, int defaultValue)
Convert the string to int.
int value = defaultValue;
if (str == null || str.length() <= 0) {
    return value;
try {
    value = Integer.parseInt(str);
} catch (NumberFormatException e) {
    value = defaultValue;
...
inttoInt(String str, int defaultValue)

Convert a String to an int, returning a default value if the conversion fails.

If the string is null, the default value is returned.

 NumberUtils.toInt(null, 1) = 1 NumberUtils.toInt("", 1)   = 1 NumberUtils.toInt("1", 0)  = 1 
if (str == null) {
    return defaultValue;
try {
    return Integer.parseInt(str);
} catch (NumberFormatException nfe) {
    return defaultValue;
inttoInt(String str, int defValue)
to Int
try {
    return Integer.parseInt(str);
} catch (Exception e) {
return defValue;
inttoInt(String str, int val)
to Int
return str != null ? Integer.parseInt(str) : val;
inttoInt(String string)
to Int
assert string.length() == 4;
int integer = 0;
for (int i = 0; i < string.length(); i++) {
    byte tmp = decodeHexChar(string.charAt(i));
    integer <<= 4;
    integer |= tmp;
return integer;
...
intToInt(String string)
To Int
try {
    return Integer.parseInt(string);
} catch (NumberFormatException e) {
    return -1;
inttoInt(String string)
to Int
if (string.length() != 4)
    throw new IllegalArgumentException(
            "length must be 4, got \"" + string + "\", length=" + string.length());
byte[] bytes = string.getBytes();
return ((bytes[0] & 0xFF) << 24) | ((bytes[1] & 0xFF) << 16) | ((bytes[2] & 0xFF) << 8) | (bytes[3] & 0xFF);
inttoInt(String string)
Convert String to an integer.
int val = 0;
boolean started = false;
boolean minus = false;
for (int i = 0; i < string.length(); i++) {
    char b = string.charAt(i);
    if (b <= ' ') {
        if (started)
            break;
...
inttoInt(String string)
string2Int
String str = trim(string);
if ("".equals(str))
    str = "0";
return Integer.parseInt(str);