IO流-设置输出字符编码格式

 

  
  
  
  
  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.     } 

 

本文出自 “天空没有痕迹但我飞过” 博客,转载请与作者联系!

你可能感兴趣的:(IO流,字符编码)