question: public static int string2int ( String s , int radix ) throws NumberFormatException { if ( radix == 10 ) { return Integer . parseInt ( s , radix ) ; } else { char [ ] cs = s . toCharArray ( ) ; int limit = Integer . MAX_VALUE / ( radix / 2 ) ; int n = 0 ; for ( int i = 0 ; i < cs . length ; i ++ ) { int d = Character . digit ( cs [ i ] , radix ) ; if ( n < 0 || n > limit || n * radix > Integer . MAX_VALUE - d ) throw new NumberFormatException ( ) ; n = n * radix + d ; } return n ; } }
target:  Convert string to integer.