List of utility methods to do Content Type Get
String | getContentType(File file) get Content Type String contentType = URLConnection.guessContentTypeFromName(file.getName()); if (contentType == null || !contentType.startsWith("image/")) { throw new IllegalArgumentException(file.getCanonicalPath() + " is not a supported image file."); return contentType; |
String | getContentType(File file) get Content Type String contentType = (URLConnection.guessContentTypeFromName(file.getName())); if ("".equals(contentType) || contentType == null) { if (file.getName().contains(".jhtml")) { contentType = "text/jhtml"; if (file.getName().contains(".jap")) { contentType = "application/jap"; if (file.getName().contains(".css")) { contentType = "text/css"; if (file.getName().contains(".js")) { contentType = "text/javascript"; return contentType; |
String | getContentType(final File file) Get a file mime type based on its filename. return getContentType(file.getName());
|
String | getContentType(final String filename) Return the contentType for a given filename if it is defined inside the JVM FileNameMap mapNew = URLConnection.getFileNameMap(); String temp = mapNew.getContentTypeFor("." + getExtension(filename)); return (temp == null) ? "application/octet-stream" : temp; |
String | getContentType(String boundary) Gets the content type string suitable for the java.net.URLConnection which includes the multipart boundary string.
return "multipart/form-data; boundary=" + boundary; |
String | getContentType(String file) Gets the content type for the specified file. String foundContentType = null; file = file.trim(); if (fileNameMap != null) foundContentType = fileNameMap.getContentTypeFor(file); if (foundContentType != null) return foundContentType; else return "application/octet-stream"; ... |
String | getContentType(String fileName) get Content Type return URLConnection.guessContentTypeFromName(fileName);
|
String | getContentType(String filename) get Content Type return filename.endsWith(".html") ? "text/html" : filename.endsWith(".css") ? "text/css" : filename.endsWith(".js") ? "text/javascript" : URLConnection.guessContentTypeFromName(filename); |
String | getContentType(String name) Gets the content type for the specified filename. String contentType; FileNameMap fileNameMap = URLConnection.getFileNameMap(); contentType = fileNameMap.getContentTypeFor(name); if (contentType == null) { int index = name.lastIndexOf("."); if (index > -1) { contentType = localFileNameMap.getProperty(name.substring(index)); return contentType; |