`
oznyang
  • 浏览: 158926 次
  • 性别: Icon_minigender_1
  • 来自: 南京
文章分类
社区版块
存档分类
最新评论

test code

阅读更多
 1 public   class  hello  {
 2      public   static   void  main(String a[])  throws  java.io.IOException  {
 3         String tmp  =   " 中文 "
 4         printHex(tmp, " Unicode " );
 5         printHex(tmp, " GB2312 " );
 6         printHex(tmp, " ISO8859-1 " );
 7         printHex(tmp, " UTF-8 " );
 8     }

 9
10      private   static   void  printHex(String str,String charset)  throws  java.io.IOException  {
11          byte [] buf  =  str.getBytes(charset);
12          for  ( int  i  =   0 ; i  <  buf.length; i ++ {
13             System.out.print(Integer.toHexString(buf[i]));
14             System.out.print( "   " );
15         }

16         System.out.println( "   " );
17     }

18
19 }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics