代码如下,想把byte数组转为字符串,但是打印出来的是乱码,请问是编码问题吗?
尝试使用默认编码也不行。
byte [] sz_crc=new byte[6];
sz_crc[0]=0x01;
sz_crc[1]=0x03;
sz_crc[2]=0x00;
sz_crc[3]=0x23;
sz_crc[4]=0x00;
String string;
try {
string = new String(sz_crc,"utf-8");
System.out.println(string);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
打印结果: