1. public class TestEncode 
  2.     public static void main(String[] args) 
  3.     { 
  4.         String str = "a工程师"
  5.         try 
  6.         { 
  7.             System.out.println(str.getBytes("gbk").length);//结果7 
  8.             System.out.println(str.getBytes("utf-8").length);//结果10 
  9.         } 
  10.         catch (UnsupportedEncodingException e) 
  11.         { 
  12.             e.printStackTrace(); 
  13.         } 
  14.     }