public static byte[] decode(char[] hexChars, int startIndex, int length) {
        if ((length & 1) != 0) {
            throw new IllegalArgumentException("Length must be even");
        }

        byte[] result = new byte[length / 2];
        for (int j = 0; j < result.length; j++) {
            result[j] = (byte) (hexCharToNibble(hexChars[startIndex++]) * 16 +
                    hexCharToNibble(hexChars[startIndex++]));
        }
        return result;
    }
Decode an array of hex chars.

@param hexChars   an array of hex characters.
@param startIndex the index of the first character to decode
@param length     the number of characters to decode.
@return the decode hex chars as bytes.
tika-core/src/main/java/org/apache/tika/mime/HexCoDec.java