UTF-8项目发送GBK报文,JAVA实现UTF-8转码为GBK

来源:互联网 发布:威锋论坛mac讨论区 编辑:程序博客网 时间:2024/05/29 15:14
String t = xml;String utf8 = new String(t.getBytes( "UTF-8"));System.out.println(utf8);String unicode = new String(utf8.getBytes(),"UTF-8");System.out.println(unicode);String gbk = new String(unicode.getBytes("GBK"));System.out.println(gbk);
不过这个方法是无法把中文转码的。中文转码需要用
URLEncoder这个方法