Code example for HttpEntity

Methods: getContentType

0
	public static String getContentCharSet(final HttpEntity entity) throws ParseException {
 
		if (entity == null) { throw new IllegalArgumentException("HTTP entity may not be null"); }
		String charset = null;
 
		if (entity.getContentType() != null) {
 
			HeaderElement values[] = entity.getContentType().getElements();
			if (values.length > 0) {
				NameValuePair param = values[0].getParameterByName("charset");
	 
				if (param != null) {
					charset = param.getValue();
				} 
			} 
		} 
		return charset;
	} 
}