ITeye博客

test code

oznyang · 2006-09-28 13:42 · Java · Markdown

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 }

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。