Here you can find the source of getCharsetFromContentTypeString(String contentType)
public static String getCharsetFromContentTypeString(String contentType)
//package com.java2s; import java.nio.charset.Charset; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String getCharsetFromContentTypeString(String contentType) { if (contentType != null) { String pattern = "charset=([a-z\\d\\-]*)"; Matcher matcher = Pattern.compile(pattern, Pattern.CASE_INSENSITIVE).matcher(contentType); if (matcher.find()) { String charset = matcher.group(1); if (Charset.isSupported(charset)) { return charset; }/* w w w . jav a2s . co m*/ } } return null; } }