您的位置:首页 > 编程语言 > Java开发

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

2017-11-30 16:38 344 查看
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这个方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: