public static String getCharsetOfContentType(String rawContentType, String defaultEncoding) {
    """
	A http content type should contain a character set like
	"application/json; charset=utf-8".
	
	If you only want to get the character set you can use this method.
	
	See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1
	
	@param rawContentType "application/json; charset=utf-8" or "application/json"
	@return only the character set like utf-8 OR the defaultEncoding when not set
    """
        
        if (rawContentType.contains("charset=")) {
            String charset = rawContentType.split("charset=") [1];
       
            return charset;
        } else {
            return defaultEncoding;
        }
        
    }
public static String getCharsetOfContentType(String rawContentType, String defaultEncoding) {
        
        if (rawContentType.contains("charset=")) {
            String charset = rawContentType.split("charset=") [1];
       
            return charset;
        } else {
            return defaultEncoding;
        }
        
    }
public static String getCharsetOfContentType ( String rawContentType , String defaultEncoding ) { if ( rawContentType . contains ( "charset=" ) ) { String charset = rawContentType . split ( "charset=" ) [ 1 ] ; return charset ; } else { return defaultEncoding ; } }
A http content type should contain a character set like
"application/json; charset=utf-8".

If you only want to get the character set you can use this method.

See also: http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.7.1

@param rawContentType "application/json; charset=utf-8" or "application/json"
@return only the character set like utf-8 OR the defaultEncoding when not set
A http content type should contain a character set like application / json ; charset = utf - 8 .