SimpleTypeDetector { public static void main(String[] args) throws Exception { Tika tika = new Tika(); for (String file : args) { String type = tika.detect(new File(file)); System.out.println(file + ": " + type); } }  static void main(String[] args);  }
@Test public void testSimpleTypeDetector() throws Exception { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); PrintStream out = System.out; System.setOut(new PrintStream(buffer, true, UTF_8.name())); SimpleTypeDetector.main(new String[] { "pom.xml" }); System.setOut(out); assertEquals("pom.xml: application/xml", buffer.toString(UTF_8.name()).trim()); }