ZeroSizeFileDetector implements Detector { public MediaType detect(InputStream stream, Metadata metadata) throws IOException { if (stream != null) { try { stream.mark(1); if (stream.read() == -1) { return MediaType.EMPTY; } } finally { stream.reset(); } } return MediaType.OCTET_STREAM; }  MediaType detect(InputStream stream, Metadata metadata);  }
@Test public void testDetectZeroValue() { byte[] data = "".getBytes(UTF_8); detect(data, MediaType.EMPTY); }
@Test public void testDetectNonZeroValue() { byte[] data = "Testing 1...2...3".getBytes(UTF_8); detect(data, MediaType.OCTET_STREAM); }