@Test public void testGetMimeTypeForFile() throws Exception { File myFile = new File("ReadMe"); assertThat(MimeTypes.getMimeTypeForFile(myFile)).isEqualTo(MimeTypes.BINARY); assertThat(MimeTypes.getMimeTypeForFile((File) null)).isEqualTo(null); myFile = new File("ReadMe.kitten"); assertThat(MimeTypes.getMimeTypeForFile(myFile)).isEqualTo(MimeTypes.BINARY); myFile = new File("ReadMe.jpg"); assertThat(MimeTypes.getMimeTypeForFile(myFile)).isEqualTo("image/jpeg"); }
public static String getMimeTypeForFile(File file) { if (file == null) { return null; } String name = file.getName(); if (name.indexOf('.') == -1) { return BINARY; } else { String ext = name.substring(name.lastIndexOf('.') + 1); String mime = KnownMimeTypes.getMimeTypeByExtension(ext); if (mime == null) { return BINARY; } else { return mime; } } }
MimeTypes { public static String getMimeTypeForFile(File file) { if (file == null) { return null; } String name = file.getName(); if (name.indexOf('.') == -1) { return BINARY; } else { String ext = name.substring(name.lastIndexOf('.') + 1); String mime = KnownMimeTypes.getMimeTypeByExtension(ext); if (mime == null) { return BINARY; } else { return mime; } } } }
MimeTypes { public static String getMimeTypeForFile(File file) { if (file == null) { return null; } String name = file.getName(); if (name.indexOf('.') == -1) { return BINARY; } else { String ext = name.substring(name.lastIndexOf('.') + 1); String mime = KnownMimeTypes.getMimeTypeByExtension(ext); if (mime == null) { return BINARY; } else { return mime; } } } private  MimeTypes(); }
MimeTypes { public static String getMimeTypeForFile(File file) { if (file == null) { return null; } String name = file.getName(); if (name.indexOf('.') == -1) { return BINARY; } else { String ext = name.substring(name.lastIndexOf('.') + 1); String mime = KnownMimeTypes.getMimeTypeByExtension(ext); if (mime == null) { return BINARY; } else { return mime; } } } private  MimeTypes(); static String getMimeTypeForFile(File file); static String getMimeTypeForFile(URL url); }
MimeTypes { public static String getMimeTypeForFile(File file) { if (file == null) { return null; } String name = file.getName(); if (name.indexOf('.') == -1) { return BINARY; } else { String ext = name.substring(name.lastIndexOf('.') + 1); String mime = KnownMimeTypes.getMimeTypeByExtension(ext); if (mime == null) { return BINARY; } else { return mime; } } } private  MimeTypes(); static String getMimeTypeForFile(File file); static String getMimeTypeForFile(URL url); static final String TEXT; static final String HTML; static final String JSON; static final String XML; static final String CSS; static final String JAVASCRIPT; static final String FORM; static final String EVENT_STREAM; static final String BINARY; static final String MULTIPART; }