當前位置: 首頁>>代碼示例>>Java>>正文


Java HTTP.DEFAULT_CONTENT_CHARSET屬性代碼示例

本文整理匯總了Java中org.apache.http.protocol.HTTP.DEFAULT_CONTENT_CHARSET屬性的典型用法代碼示例。如果您正苦於以下問題:Java HTTP.DEFAULT_CONTENT_CHARSET屬性的具體用法?Java HTTP.DEFAULT_CONTENT_CHARSET怎麽用?Java HTTP.DEFAULT_CONTENT_CHARSET使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.http.protocol.HTTP的用法示例。


在下文中一共展示了HTTP.DEFAULT_CONTENT_CHARSET屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: StringEntity

/**
 * Creates a StringEntity with the specified content, MIME type and charset
 *
 * @param string content to be used. Not {@code null}.
 * @param mimeType MIME type to be used. May be {@code null}, in which case the default
 *   is {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain"
 * @param charset character set to be used. May be {@code null}, in which case the default
 *   is {@link HTTP#DEF_CONTENT_CHARSET} i.e. "ISO-8859-1"
 *
 * @since 4.1
 * @throws IllegalArgumentException if the string parameter is null
 *
 * @deprecated (4.1.3) use {@link #StringEntity(String, ContentType)}
 */
@Deprecated
public StringEntity(final String string, String mimeType, String charset)
        throws UnsupportedEncodingException {
    super();
    if (string == null) {
        throw new IllegalArgumentException("Source string may not be null");
    }
    if (mimeType == null) {
        mimeType = HTTP.PLAIN_TEXT_TYPE;
    }
    if (charset == null) {
        charset = HTTP.DEFAULT_CONTENT_CHARSET;
    }
    this.content = string.getBytes(charset);
    setContentType(mimeType + HTTP.CHARSET_PARAM + charset);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:30,代碼來源:StringEntity.java

示例2: parseCharset

/**
 * Returns the charset specified in the Content-Type of this header,
 * or the HTTP default (ISO-8859-1) if none can be found.
 */
public static String parseCharset(Map<String, String> headers) {
    String contentType = headers.get(HTTP.CONTENT_TYPE);
    if (contentType != null) {
        String[] params = contentType.split(";");
        for (int i = 1; i < params.length; i++) {
            String[] pair = params[i].trim().split("=");
            if (pair.length == 2) {
                if (pair[0].equals("charset")) {
                    return pair[1];
                }
            }
        }
    }

    return HTTP.DEFAULT_CONTENT_CHARSET;
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:20,代碼來源:HttpHeaderParser.java


注:本文中的org.apache.http.protocol.HTTP.DEFAULT_CONTENT_CHARSET屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。