ContentType ct; try { ct = new ContentType(contentType);  if (!ct.match(CT_TEXT_WILD)) throw new IllegalArgumentException("unsupported content type: " + contentType); } catch (ParseException e1) {  ct = new ContentType("text", "plain", null); }
ContentType ct = new ContentType(contentType);  if (!ct.getValue().matches(CT_TEXT_WILD)) throw new IllegalArgumentException("unsupported content type: " + contentType);
    public static String getCharset(String contentType) {        ContentType ct;        try {            ct = new ContentType(contentType);            // we shouldn't get called with anything other then text/*, but if we do...            if (!ct.match(CT_TEXT_WILD))                throw new IllegalArgumentException("unsupported content type: " + contentType);                    } catch (ParseException e1) {            // TODO: treat as text/plain? run some sanity checks on it?            ct = new ContentType("text", "plain", null);        }           String charset = ct.getParameter(Mime.P_CHARSET);        if (charset == null)            charset = Mime.P_CHARSET_DEFAULT;        return charset;    }