Java Utililty Methods atoi

List of utility methods to do atoi

Description

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

Method

intatoi(byte[] s)
atoi
int result = 0;
boolean negative = false;
int i = 0, len = s.length;
int limit = -Integer.MAX_VALUE;
int multmin;
int digit;
if (len > 0) {
    byte firstChar = s[0];
...
intatoi(byte[] s, int offset)
atoi
StringBuilder sb = new StringBuilder();
char c;
while ((c = (char) (s[offset++] & 0xFF)) != 0 && Character.isDigit(c)) {
    sb.append(c);
if (sb.length() == 0) {
    return 0;
return Integer.parseInt(sb.toString());
intatoi(final String s, final int base)
atoi
try {
    return Integer.parseInt(s, base);
} catch (Throwable ex) {
    return 0;
intatoi(final String s, final int def)
atoi
int result = 0;
int i = 0;
final int len = s.length();
int digit;
while (i < len) {
    digit = s.charAt(i++) - '0';
    if (digit < 0 || 9 < digit)
        return def;
...
intatoi(final String str, final int def)
atoi
try {
    return Integer.parseInt(str);
} catch (final Exception ex) {
    ex.printStackTrace();
return def;
intatoi(Object s)
atoi
int i = 0;
if (s != null) {
    String n = s.toString();
    int dot = n.indexOf('.');
    if (dot != -1) {
        n = n.substring(0, dot);
    try {
...
intatoi(String s)
atoi
if (s == null || s.length() < 1)
    throw new IllegalArgumentException("Can't convert empty string to integer");
if (s.charAt(0) == '+')
    s = s.substring(1);
return Integer.parseInt(s);
intatoi(String s)
atoi
int value = 0;
try {
    value = Integer.parseInt(s);
} catch (NumberFormatException ex) {
    value = 0;
return value;
intatoi(String s)
Returns the integer value of s.
int i, numMinuses = 0;
s = s.trim();
for (i = 0; i < s.length() && (s.charAt(i) == '-' || Character.isDigit(s.charAt(i))); i++)
    if (s.charAt(i) == '-')
        numMinuses++;
if (i != 0 && numMinuses < 2)
    return Integer.parseInt(s.substring(0, i));
return 0;
...
intatoi(String s)
atoi
return Integer.parseInt(s);