private String readByteArray() {
        StringBuffer buf = new StringBuffer();

        int count = 0;
        char w = (char) 0;

        // read individual bytes and format into a character array
        while ((loc < stream.length) && (stream[loc] != '>')) {
            char c = (char) stream[loc];
            byte b = (byte) 0;

            if (c >= '0' && c <= '9') {
                b = (byte) (c - '0');
            } else if (c >= 'a' && c <= 'f') {
                b = (byte) (10 + (c - 'a'));
            } else if (c >= 'A' && c <= 'F') {
                b = (byte) (10 + (c - 'A'));
            } else {
                loc++;
                continue;
            }

            // calculate where in the current byte this character goes
            int offset = 1 - (count % 2);
            w |= (0xf & b) << (offset * 4);

            // increment to the next char if we've written four bytes
            if (offset == 0) {
                buf.append(w);
                w = (char) 0;
            }

            count++;
            loc++;
        }

        // ignore trailing '>'
        loc++;

        return buf.toString();
    }