public void parse(InputStream stream, ContentHandler handler, Metadata metadata,
                      ParseContext context) throws IOException, SAXException, TikaException {

        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        Last5 l5 = new Last5();
        int read;

        // Try to get the creation date, which is YYYYMMDDhhmm
        byte[] header = new byte[30];
        IOUtils.readFully(stream, header);
        byte[] date = new byte[12];
        IOUtils.readFully(stream, date);

        String dateStr = new String(date, US_ASCII);
        if (dateStr.startsWith("19") || dateStr.startsWith("20")) {
            String formattedDate = dateStr.substring(0, 4) + "-" + dateStr.substring(4, 6) + "-" +
                    dateStr.substring(6, 8) + "T" + dateStr.substring(8, 10) + ":" +
                    dateStr.substring(10, 12) + ":00";
            metadata.set(TikaCoreProperties.CREATED, formattedDate);
            // TODO Metadata.DATE is used as modified, should it be here?
            metadata.set(TikaCoreProperties.CREATED, formattedDate);
        }
        metadata.set(Metadata.CONTENT_TYPE, PRT_MIME_TYPE);

        // The description, if set, is the next up-to-500 bytes
        byte[] desc = new byte[500];
        IOUtils.readFully(stream, desc);
        String description = extractText(desc, true);
        if (description.length() > 0) {
            metadata.set(TikaCoreProperties.DESCRIPTION, description);
        }

        // Now look for text
        while ((read = stream.read()) > -1) {
            if (read == 0xe0 || read == 0xe3 || read == 0xf0) {
                int nread = stream.read();
                if (nread == 0x3f || nread == 0xbf) {
                    // Looks promising, check back for a suitable value
                    if (read == 0xe3 && nread == 0x3f) {
                        if (l5.is33()) {
                            // Bingo, note text
                            handleNoteText(stream, xhtml);
                        }
                    } else if (l5.is00()) {
                        // Likely view name
                        handleViewName(read, nread, stream, xhtml, l5);
                    }
                }
            } else {
                l5.record(read);
            }
        }
    }
How long do we allow a text run to claim to be, before we
decide we're confused and it's not really text after all?
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-cad-module/src/main/java/org/apache/tika/parser/prt/PRTParser.java