code: public static byte[] hexToByte(String s) throws IOException {
  
          int  l      = s.length() / 2;
          byte data[] = new byte[l];
          int  j      = 0;
  
          if (s.length() % 2 != 0) {
              throw new IOException(
                                    "hexadecimal string with odd number of characters");
          }
  
          for (int i = 0; i < l; i++) {
              char c = s.charAt(j++);
              int  n, b;
  
              n = HEXINDEX.indexOf(c);
  
              if (n == -1) {
                  throw new IOException(
                                        "hexadecimal string contains non hex character");
              }
  
              b       = (n & 0xf) << 4;
              c       = s.charAt(j++);
              n       = HEXINDEX.indexOf(c);
              b       += (n & 0xf);
              data[i] = (byte) b;
          }
  
          return data;
      }
docs: Compacts a hexadecimal string into a byte array
  
  
  @param s hexadecimal string
  
  @return byte array for the hex string
  @throws IOException 非16进制字符或者超长时抛出