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

        XHTMLContentHandler xhtml = new XHTMLContentHandler(handler, metadata);
        xhtml.startDocument();

        EmbeddedDocumentExtractor extractor =
                EmbeddedDocumentUtil.getEmbeddedDocumentExtractor(context);

        Path cwd = Files.createTempDirectory("tika-unrar-");
        try {
            Path tmp = Files.createTempFile(cwd, "input", ".rar");
            try (OutputStream os = Files.newOutputStream(tmp, StandardOpenOption.WRITE)) {
                IOUtils.copy(stream, os);
            }
            FileProcessResult result = unrar(cwd, tmp);
            //delete the tmp rar file so that we don't recursively parse it in the next step
            try {
                Files.delete(tmp);
            } catch (IOException e) {
                //warn failed to delete tmp
            }
            if (result.isTimeout()) {
                throw new TikaTimeoutException("timed out unrarring");
            } else if (result.getExitValue() != 0) {
                if (result.getStderr().contains("error in the encrypted file")) {
                    throw new EncryptedDocumentException();
                }
                String msg = result.getStderr();
                if (msg.length() > 100) {
                    msg = msg.substring(0, 100);
                }
                throw new TikaException("Unrecoverable problem with rar file, exitValue=" +
                        result.getExitValue() + " : " + msg);
            }
            //TODO: process stdout to extract status for each file:
            //e.g. Extracting  test-documents/testEXCEL.xls                              OK
            processDirectory(cwd, cwd, xhtml, extractor, context);
        } finally {
            FileUtils.deleteDirectory(cwd.toFile());
        }
        xhtml.endDocument();
    }
Parser for Rar files.  This relies on 'unrar' being installed
and on the path.  This is not the default rar parser and must
be selected via the tika-config.xml.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pkg-module/src/main/java/org/apache/tika/parser/pkg/UnrarParser.java