public static long parseLong(String string,int radix) throws NumberFormatException {
  if (radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
    throw new NumberFormatException("Invalid radix: " + radix);
  }
  if (string == null) {
    throw invalidLong(string);
  }
  int length=string.length(), i=0;
  if (length == 0) {
    throw invalidLong(string);
  }
  boolean negative=string.charAt(i) == '-';
  if (negative && ++i == length) {
    throw invalidLong(string);
  }
  return parse(string,i,radix,negative);
}

public static long parseLong ( String string , int radix ) throws NumberFormatException { if ( radix < Character . MIN_RADIX || radix > Character . MAX_RADIX ) { throw new NumberFormatException ( "Invalid radix: " + radix ) ; } if ( string == null ) { throw invalidLong ( string ) ; } int length = string . length ( ) , i = 0 ; if ( length == 0 ) { throw invalidLong ( string ) ; } boolean negative = string . charAt ( i ) == '-' ; if ( negative && ++ i == length ) { throw invalidLong ( string ) ; } return parse ( string , i , radix , negative ) ; }
parses the string argument as a signed long in the radix specified by the second argument . the characters in the string must all be digits of the specified radix ( as determined by whether character . digit returns a nonnegative value ) , except that the first character may be an ascii minus sign ' - ' ( ' u002d ' to indicate a negative value . the resulting long value is returned . note that neither l nor l is permitted to appear at the end of the string as a type indicator , as would be permitted in java programming language source code - except that either l or l may appear as a digit for a radix greater than 22 . an exception of type numberformatexception is thrown if any of the following situations occurs : the first argument is null or is a string of length zero . the radix is either smaller than character . min_radix or larger than character . max_radix . the first character of the string is not a digit of the specified radix and is not a minus sign ' - ' ( ' u002d ' ) . the first character of the string is a minus sign and the string is of length 1 . any character of the string after the first is not a digit of the specified radix . the integer value represented by the string cannot be represented as a value of type long . examples : parselong ( " 0 " , 10 ) returns 0l parselong ( " 473 " , 10 ) returns 473l parselong ( " - 0 " , 10 ) returns 0l parselong ( " - ff " , 16 ) returns - 255l parselong ( " 1100110 " , 2 ) returns 102l parselong ( " 99 " , 8 ) throws a numberformatexception parselong ( " hazelnut " , 10 ) throws a numberformatexception parselong ( " hazelnut " , 36 ) returns 1356099454469l
