联系客服:400-805-1963

IO流-设置输出字符编码格式
更新:HHH   时间:2023-1-7


 

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

 

返回开发技术教程...