public static byte[] hexStringToBytes(String s) {
        byte[] ret;

        if (s == null) {
            return null;
        }

        int sz = s.length();
        ret = new byte[sz / 2];
        for (int i = 0; i < sz; i += 2) {
            ret[i / 2] = (byte) ((hexCharToInt(s.charAt(i)) << 4) | hexCharToInt(s.charAt(i + 1)));
        }

        return ret;
    }
Converts a hex String to a byte array.

@param s
           A string of hexadecimal characters, must be an even number of
           chars long

@return byte array representation

@throws RuntimeException
            on invalid format
replugin-host-library/replugin-host-lib/src/main/java/com/qihoo360/replugin/utils/basic/ByteConvertor.java