java中使用encode转码和解码

String str = URLEncoder.encode("中国","utf-8");
System.out.println(str);
//解码
String str1=URLDecoder.decode(str, "UTF-8");
System.out.println(str1);

打印结果

%E4%B8%AD%E5%9B%BD
中国

posted on 2016-11-02 10:26  wonder2636  阅读(50594)  评论(0编辑  收藏  举报

导航