private static int toDigit(final char ch,final int index){
  final int digit=Character.digit(ch,16);
  if (digit == -1) {
    throw new RuntimeException("Illegal hexadecimal character " + ch + " at index "+ index);
  }
  return digit;
}

private static int toDigit ( final char ch , final int index ) { final int digit = Character . digit ( ch , 16 ) ; if ( digit == - 1 ) { throw new RuntimeException ( "Illegal hexadecimal character " + ch + " at index " + index ) ; } return digit ; }
converts a hexadecimal character to an integer .
