code: public static byte[] hexToBytes(String hexString) {
          byte[] result = new byte[hexString.length() / 2];
          for (int i = 0; i < result.length; ++i) {
              int offset = i * 2;
              result[i] = (byte) Integer.parseInt(hexString.substring(offset,
                  offset + 2), 16);
          }
          return result;
      }
docs: Takes a string in hexadecimal format and converts it to a binary byte
  array. This does no checking of the format of the input, so this should
  only be used after confirming the format or origin of the string. The input
  string should only contain the hex data, two characters per byte.