private void extractOutput(InputStream stream, XHTMLContentHandler xhtml)
            throws SAXException, IOException {
        try (Reader reader = new InputStreamReader(stream, UTF_8)) {
            xhtml.startDocument();
            xhtml.startElement("p");
            char[] buffer = new char[1024];
            for (int n = reader.read(buffer); n != -1; n = reader.read(buffer)) {
                xhtml.characters(buffer, 0, n);
            }
            xhtml.endElement("p");
            xhtml.endDocument();
        }
    }
Starts a thread that extracts the contents of the standard output
stream of the given process to the given XHTML content handler.
The standard output stream is closed once fully processed.

@param stream
@param xhtml  XHTML content handler
@throws SAXException if the XHTML SAX events could not be handled
@throws IOException  if an input error occurred
tika-core/src/main/java/org/apache/tika/parser/external/ExternalParser.java