SimpleTextExtractor { public static void main(String[] args) throws Exception { Tika tika = new Tika(); for (String file : args) { String text = tika.parseToString(new File(file)); System.out.print(text); } }  static void main(String[] args);  }
@Test public void testSimpleTextExtractor() throws Exception { String message = "This is Tika - Hello, World! This is simple UTF-8 text" + " content written in English to test autodetection of" + " the character encoding of the input stream."; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); PrintStream out = System.out; System.setOut(new PrintStream(buffer, true, UTF_8.name())); File file = new File("target", "test.txt"); FileUtils.writeStringToFile(file, message, UTF_8); SimpleTextExtractor.main(new String[] { file.getPath() }); file.delete(); System.setOut(out); assertEquals(message, buffer.toString(UTF_8.name()).trim()); }