System.out.println("________________________sample1______________________________");
String a="我是林纳斯";
System.out.println("“我是林纳斯”这句话的的按utf-8解码的字节数组为:"+Arrays.toString(a.getBytes(StandardCharsets.UTF_8)));
System.out.println("字节数组按utf-8编码为: "+new String(new byte[]{-26, -120, -111, -26, -104, -81, -26, -98, -105, -25, -70, -77, -26, -106, -81}));
System.out.println("________________________sample2______________________________");
System.out.println("字节数组按utf-8编码为: "+new String(new byte[]{18, 52, 86, 120, -102, -68, -34, -1, -19, -53, -87, -121, 101, 67, 33}));
System.out.println("“4Vx�����˩�eC!”按utf-8解码为: "+"4Vx�����˩�eC!".getBytes(StandardCharsets.UTF_8));
正常中文编码解码相同,但如果不是正常汉字的编码在解码时会出现乱码