编码:把字符串转换成字节数组 解码:把字节数组转换成字符串
byte[] bytes
= "好好学习,天天向上".getBytes();
String s
= new String(bytes
);
System
.out
.println(s
);
byte[] bytes1
= "好好学习,天天向上".getBytes("GBK");
String string
= new String(bytes1
, "GBK");
System
.out
.println(string
);
注意: 编码和解码的码表要一致,即用什么编码,就用什么解码;