Java examples for Network:Mime Type
Returns a default extension for a given mime-type, or an empty string if the mimetype is unknown.
//package com.java2s; public class Main { /**/*from ww w .java 2s . c o m*/ * Returns a default extension for a given mime-type, or an * empty string if the mimetype is unknown. * @param type * @return extension */ public static String getExtension(String type) { if (type.equals("application/msword")) return "doc"; if (type.equals("application/pdf")) return "pdf"; if (type.equals("application/vnd.oasis.opendocument.text")) return "odt"; if (type.equals("application/vnd.sun.xml.calc")) return "sxc"; if (type.equals("application/x-javascript") || type.equals("text/javascript")) return "js"; if (type.equals("application/x-xpinstall")) return "xpi"; if (type.equals("application/zip")) return "zip"; if (type.equals("image/bmp")) return "bmp"; if (type.equals("image/gif")) return "gif"; if (type.equals("image/tiff")) return "tif"; if (type.equals("image/jpeg")) return "jpg"; if (type.equals("image/png")) return "png"; if (type.equals("text/css")) return "css"; if (type.equals("text/html") || type.equals("application/xhtml+xml")) return "html"; if (type.equals("text/plain")) return "txt"; if (type.equals("text/xml") || type.equals("application/xml")) return "xml"; if (type.equals("video/quicktime")) return "mov"; if (type.equals("")) return ""; // TODO: add more return ""; } }