int parseInt(String s) throws NumberFormatException {
                int radix;
                int i;
                if( s.startsWith("0x") || s.startsWith("0X") ) {
                        radix = 16;
                        i = 2;
                } else if( s.startsWith("0") && s.length() > 1 ) {
                        radix = 8;
                        i = 1;
                } else {
                        radix = 10;
                        i = 0;
                }
                int result = 0;
                int len = s.length();
                for( ; i<len; i++ ) {
                        if( result < 0 )
                                throw new NumberFormatException("Number too big for integer type: "+s);
                        result *= radix;
                        int digit = Character.digit(s.charAt(i),radix);
                        if( digit < 0 )
                                throw new NumberFormatException("Invalid integer type: "+s);
                        result += digit;
                }
                return result;
        }