List of utility methods to do Mime Type Get
String | extractMimeType(byte[] imageData) extract Mime Type try (ByteArrayInputStream input = new ByteArrayInputStream(imageData)) { String contentType = URLConnection.guessContentTypeFromStream(input); return contentType != null ? contentType : "image/xyz"; |
String | getExactMimeType(String fileName) This gets the MIME type of a file, based on its name. if (fileName == null) return null; String mimeType = URLConnection.getFileNameMap().getContentTypeFor(fileName); if (mimeType == null) { try { String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase(); if ("js".equals(suffix)) mimeType = "text/javascript"; ... |
String | getMimeType(File file) Try to detect MimeType by backwards compatible methods String guess = null; if (file != null && file.exists() && file.isFile()) { InputStream is = null; try { is = new BufferedInputStream(new FileInputStream(file)); guess = URLConnection.guessContentTypeFromStream(is); } catch (IOException e) { e.printStackTrace(); ... |
String | getMimeType(String file) get Mime Type FileNameMap fileNameMap = URLConnection.getFileNameMap();
String type = fileNameMap.getContentTypeFor(file);
return type;
|
String | getMimeType(String fileName) Attempts to determine the MIME type of the specified file. FileNameMap fileNameMap = URLConnection.getFileNameMap(); String mimeType = fileNameMap.getContentTypeFor(fileName); if (mimeType != null) return mimeType; return "application/octet-stream"; |
String | getMIMEType(String fileName) Returns the MIME type of the given file name. FileNameMap fileNameMap = URLConnection.getFileNameMap();
return fileNameMap.getContentTypeFor(fileName);
|
String | getMimeType(String fileName) Get the mime type for the specified filename if (fileName.contains(".")) { String extension = fileName.substring(fileName.lastIndexOf('.') + 1); if (mimeTypes.containsKey(extension)) { return mimeTypes.get(extension); String defaultMime = fileNameMap.getContentTypeFor(fileName); if (defaultMime != null) { ... |
String | getMimeType(String fileName) This gets the MIME type of a file, based on its name. if (fileName == null) return null; String mimeType = getExactMimeType(fileName); if (mimeType == null) mimeType = "untyped/binary"; return mimeType; |
String | getMimeTypeByFileName(String fileName) get Mime Type By File Name if (fileName == null) return DEFAULT_MIME_TYPE; String en = URLConnection.getFileNameMap().getContentTypeFor(fileName); return en != null ? en : DEFAULT_MIME_TYPE; |
String | getMimeTypeForFile(File memberFile) get Mime Type For File URL fileUrl; String mimeType = ""; try { fileUrl = memberFile.toURI().toURL(); URLConnection c = fileUrl.openConnection(); mimeType = c.getContentType(); } catch (MalformedURLException e) { e.printStackTrace(); ... |