public TextExtractionResult Extract(string filePath) { if (!System.IO.File.Exists(filePath)) throw new System.ArgumentException("File does not exist"); var parser = new AutoDetectParser(); var metadata = new Metadata(); var parseContext = new ParseContext(); Class parserClass = parser.GetType(); parseContext.set(parserClass, parser); try { var file = new File(filePath); var url = file.toURI().toURL(); using (var inputStream = TikaInputStream.get(url, metadata)) { parser.parse(inputStream, getTransformerHandler(), metadata, parseContext); inputStream.close(); } return assembleExtractionResult(_outputWriter.toString(), metadata); } catch (Exception ex) { throw new ApplicationException(string.Format("Extraction of text from the file '{0}' failed.", filePath), ex); } }