java接收中文输入并正常显示

class chinese
{
 public static void main(String[] args)
 {
    byte []by=new byte[64];
                 String temp="";
                 int len=0;

                 try {
                     len=System.in.read(by);  
                     byte []byt=new byte[len];
                     for (int i = 0; i < len; i++) {
                         byt[i]=by[i];
                     }

                                 temp=new String(byt);
                                
                              //   temp=new String(temp.getBytes("UTF8 "),"UTF8");
                                 }
                                 catch (Exception ex) {
                     System.out.println("ex:"+ex.getMessage());
                 }
                                 System.out.print(temp);

 }
}

 

posted @ 2007-01-03 00:38  ahuo  阅读(522)  评论(0编辑  收藏  举报