public boolean findInFile(String query, Path path) { InterruptingContentHandler handler = new InterruptingContentHandler(query); Metadata metadata = new Metadata(); ParseContext context = new ParseContext(); context.set(Parser.class, tika.getParser()); try (InputStream is = new BufferedInputStream(Files.newInputStream(path))) { tika.getParser().parse(is, handler, metadata, context); } catch (QueryMatchedException e) { return true; } catch (SAXException | TikaException | IOException e) { // something went wrong with parsing... e.printStackTrace(); } return false; }
ParseRunner runner = new ParseRunner( source, tika.getParser(), tikainput, this.getHandler( content ), metadata, context ); try { TimeLimiter.run(runner, parseTimeout, true);
ParseRunner runner = new ParseRunner( source, tika.getParser(), tikainput, this.getHandler( content ), metadata, context ); try { TimeLimiter.run(runner, parseTimeout, true);