public static byte[] hex(String hex) {
        if (hex == null)
            return null;

        int len = hex.length();
        if (len % 2 != 0)
            return null;

        char[] chars = hex.toCharArray();
        byte[] bytes = new byte[len / 2];
        for (int i = 0; i < bytes.length; i++) {
            char c0 = chars[i * 2];
            char c1 = chars[i * 2 + 1];
            int b0 = c0 - (c0 <= 57 ? 48 : 55);
            int b1 = c1 - (c1 <= 57 ? 48 : 55);
            bytes[i] = (byte) ((b0 << 4) | b1);
        }
        return bytes;
    }
Decode hex string to a byte array

@param hex encoded string
@return return array of byte to encode
src/test/java/com/alibaba/json/bvt/writeClassName/WriteClassNameTest_bytes.java