posts - 19, comments - 1, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

test code

Posted on 2006-09-28 13:42 xyang 阅读(199) 评论(0)  编辑  收藏
 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 }

只有注册用户登录后才能发表评论。


网站导航: