我尝试从字节数组中提取输入数据,就像msg=byte[7064],
一样,因此我需要从byte []中提取数据,在我尝试过的代码下面
byte []但=新的字节[[byte)msg];
当我尝试运行它时,它引发了Classcast异常,我尝试了运气,但找不到任何解决方案,将不胜感激
转换字节后,我需要转换为字符串数据,输出像name=walterwhite, job=teacher
答案 0 :(得分:1)
下面的一个是正确的。
已转换的字符串=新的字符串((byte [])msg,StandardCharsets.ISO_8859_1 );
答案 1 :(得分:0)
public static void main(String[] args) {
byte[] bytes = "hello world".getBytes();
String s = new String(bytes);
System.out.println("s = " + s);
}