1. byte[]转String
String str = new String(bytes,"utf-8");
2.当byte[]存在多余的byte时,可以用split("\0")截取有效的字符串(,字符串默认的结束符合为 "\0")
String str = new String(bytes,"utf-8").split("\0")[0];
1. byte[]转String
String str = new String(bytes,"utf-8");
2.当byte[]存在多余的byte时,可以用split("\0")截取有效的字符串(,字符串默认的结束符合为 "\0")
String str = new String(bytes,"utf-8").split("\0")[0];
本文标题:byte[]转string去掉多余byte[]导致的乱码
本文链接:https://www.haomeiwen.com/subject/vxmezktx.html
网友评论