private void doExtract(InputStream stream, XHTMLContentHandler xhtml, String tableTitle,
                           String frames, String vecSize) throws SAXException, IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, UTF_8))) {
            String line = null;
            AttributesImpl attributes = new AttributesImpl();
            attributes.addAttribute("", "", "rows", "CDATA", frames);
            attributes.addAttribute("", "", "cols", "CDATA", vecSize);

            xhtml.startElement("h3");
            xhtml.characters(tableTitle);
            xhtml.endElement("h3");
            xhtml.startElement("table", attributes);
            while ((line = reader.readLine()) != null) {
                xhtml.startElement("tr");
                for (String val : line.split(" ")) {
                    xhtml.startElement("td");
                    xhtml.characters(val);
                    xhtml.endElement("td");
                }
                xhtml.endElement("tr");
            }
            xhtml.endElement("table");
        }
    }
Reads the contents of the given stream and write it to the given XHTML
content handler. The stream is closed once fully processed.

@param stream     Stream where is the result of ocr
@param xhtml      XHTML content handler
@param tableTitle The name of the matrix/table to display.
@param frames     Number of frames read from the video.
@param vecSize    Size of the OF or HOG vector.
@throws SAXException if the XHTML SAX events could not be handled
@throws IOException  if an input error occurred
tika-parsers/tika-parsers-ml/tika-parser-advancedmedia-module/src/main/java/org/apache/tika/parser/pot/PooledTimeSeriesParser.java