Java tutorial
//package com.java2s; public class Main { private static String readEncoding(String contentEncoding, String contentType, String fallback) { String encoding = fallback; String[] values = contentType.split(";"); if (contentEncoding != null) { encoding = contentEncoding; } else { for (String value : values) { value = value.trim(); if (value.toLowerCase().startsWith("charset=")) { encoding = value.substring("charset=".length()); } } } return encoding; } }