FileDocCategorySizeDatePackage
ContentType.javaAPI DocGlassfish v2 API4078Fri May 04 22:33:14 BST 2007org.apache.tomcat.util.http

ContentType

public class ContentType extends Object
Usefull methods for Content-Type processing
author
James Duncan Davidson [duncan@eng.sun.com]
author
James Todd [gonzo@eng.sun.com]
author
Jason Hunter [jch@eng.sun.com]
author
Harish Prabandham
author
costin@eng.sun.com

Fields Summary
Constructors Summary
Methods Summary
public static java.lang.StringgetCharsetFromContentType(java.lang.String type)

        if (type == null) {
            return null;
        }
        int semi = type.indexOf(";");
        if (semi == -1) {
            return null;
        }
        int charsetLocation = type.indexOf("charset=", semi);
        if (charsetLocation == -1) {
            return null;
        }
	String afterCharset = type.substring(charsetLocation + 8);
        // The charset value in a Content-Type header is allowed to be quoted
        // and charset values can't contain quotes.  Just convert any quote
        // chars into spaces and let trim clean things up.
        afterCharset = afterCharset.replace('"", ' ");
        String encoding = afterCharset.trim();
        return encoding;