MimetypeUtil { public String getMimeType(File file) { if (file == null) { return DEFAULT_MIMETYPE; } else { return getMimeType(file.getName()); } }  String getMimeType(File file); String getMimeType(String fileName);  }
@Test public void testMimetypeUtil() { MimetypeUtil util = new MimetypeUtil(); String mimetype = util.getMimeType("test.txt"); assertEquals("text/plain", mimetype); mimetype = util.getMimeType("test.html"); assertEquals("text/html", mimetype); mimetype = util.getMimeType(new File("test.zip")); assertEquals("application/zip", mimetype); mimetype = util.getMimeType(new File("test.000")); assertEquals("application/octet-stream", mimetype); String filename = null; mimetype = util.getMimeType(filename); assertEquals("application/octet-stream", mimetype); File file = null; mimetype = util.getMimeType(file); assertEquals("application/octet-stream", mimetype); }