public static void main(String[] args) throws Exception {
String encode = URLEncoder.encode("中文", "UTF-8"); // java.net.URLEncoder;
System.out.println(encode);
String decode = URLDecoder.decode(encode, "UTF-8"); // java.net.URLDecoder;
System.out.println(decode);
}
输出结果
%E4%B8%AD%E6%96%87
中文