public final static int parseInt(String str){
  char c=str.charAt(0);
  int length=str.length();
  boolean negative=(c == '-');
  int offset=1;
  if (negative) {
    if (length == 1 || length > 10) {
      return Integer.parseInt(str);
    }
    c=str.charAt(offset++);
  }
 else {
    if (length > 9) {
      return Integer.parseInt(str);
    }
  }
  if (c > '9' || c < '0') {
    return Integer.parseInt(str);
  }
  int num=c - '0';
  if (offset < length) {
    c=str.charAt(offset++);
    if (c > '9' || c < '0') {
      return Integer.parseInt(str);
    }
    num=(num * 10) + (c - '0');
    if (offset < length) {
      c=str.charAt(offset++);
      if (c > '9' || c < '0') {
        return Integer.parseInt(str);
      }
      num=(num * 10) + (c - '0');
      if (offset < length) {
        do {
          c=str.charAt(offset++);
          if (c > '9' || c < '0') {
            return Integer.parseInt(str);
          }
          num=(num * 10) + (c - '0');
        }
 while (offset < length);
      }
    }
  }
  return negative ? -num : num;
}

public final static int parseInt ( String str ) { char c = str . charAt ( 0 ) ; int length = str . length ( ) ; boolean negative = ( c == '-' ) ; int offset = 1 ; if ( negative ) { if ( length == 1 || length > 10 ) { return Integer . parseInt ( str ) ; } c = str . charAt ( offset ++ ) ; } else { if ( length > 9 ) { return Integer . parseInt ( str ) ; } } if ( c > '9' || c < '0' ) { return Integer . parseInt ( str ) ; } int num = c - '0' ; if ( offset < length ) { c = str . charAt ( offset ++ ) ; if ( c > '9' || c < '0' ) { return Integer . parseInt ( str ) ; } num = ( num * 10 ) + ( c - '0' ) ; if ( offset < length ) { c = str . charAt ( offset ++ ) ; if ( c > '9' || c < '0' ) { return Integer . parseInt ( str ) ; } num = ( num * 10 ) + ( c - '0' ) ; if ( offset < length ) { do { c = str . charAt ( offset ++ ) ; if ( c > '9' || c < '0' ) { return Integer . parseInt ( str ) ; } num = ( num * 10 ) + ( c - '0' ) ; } while ( offset < length ) ; } } } return negative ? - num : num ; }
helper method to ( more ) efficiently parse integer numbers from string values .
