String(byte[] bytes,String charsetName):通过指定的字符集解码字节数组
byte[] getByte(String charasetName):使用指定的字符集合吧字符串编码为字节数组
Code: to see to understand becomes not read
String-->byte[]
Decoding: can not read into the can understand
byte[]-->String
String s="你好";
//编码
//String-->byte[]:
byte[] bt=s.getBytes();//默认是GBK编码,[-60, -29, -70, -61]
//byte[] bt=s.getBytes("UTF-8");//[-28, -67, -96, -27, -91, -67]
//System.out.println(Arrays.toString(bt));
//解码(和编码的格式一定要一样,不然会出错)
//byte[]--->String
String ss=new String(bt);
System.out.println(ss);