Here you can find the source of getUrlEncoding(URLConnection connection)
public static String getUrlEncoding(URLConnection connection)
//package com.java2s; import java.net.URLConnection; import java.util.*; public class Main { public static final String defaultEncoding = "utf-8"; public static String getUrlEncoding(URLConnection connection) { String contentType = connection.getContentType(); String[] values = contentType.split(";"); String charset = defaultEncoding; // might or might not be right.... for (String value : values) { value = value.trim();//w w w . j a v a2s . c o m if (value.toLowerCase(Locale.ENGLISH).startsWith("charset=")) { charset = value.substring("charset=".length()); } } return charset; } }