| 
 
| public static void main(String[] args) throws Exception {
 String str = "田";
 byte[] buf = str.getBytes("UTF-8");  //编码
 System.out.println(Arrays.toString(buf));
 String s1 = new String(buf, "GBK");    //解码错误
 System.out.println(s1);
 
 byte[] b1 = s1.getBytes("GBK");    //对错误的解码结果进行编码
 System.out.println(Arrays.toString(b1));
 String s2 = new String(b1, "UTF-8");     //再重新按照正确的解码规则进行解码
 System.out.println(s2);
 }
 为什么我最后显示的不是'田',而是乱码
 
 
 | 
 |