code: public static int hex2bin(char c)
      {
          if (c >= '0' && c <= '9')
          {
              return (c - '0');
          }
          if (c >= 'A' && c <= 'F')
          {
              return (c - 'A' + 10);
          }
          if (c >= 'a' && c <= 'f')
          {
              return (c - 'a' + 10);
          }
          throw new IllegalArgumentException(
                  "Input string may only contain hex digits, but found '" + c
                          + "'");
      }
docs: Convert hex digit to numerical value.
  
  @param c
  0-9, a-f, A-F allowd.
  @return 0-15
  @throws IllegalArgumentException
  on non-hex character