FileUtils { static String getMimeType(File file) { final String ext = getExtension(file.getName()); if (!TextUtils.isEmpty(ext)) { return MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext); } return "application/octet-stream"; }    }
@Test public void testGetMimeType() { assertEquals("image/png", FileUtils.getMimeType(new File("file.png"))); assertEquals("image/jpeg", FileUtils.getMimeType(new File("file.jpeg"))); assertEquals("image/jpeg", FileUtils.getMimeType(new File("file.jpeg"))); assertEquals("application/octet-stream", FileUtils.getMimeType(new File(""))); }