您的位置:程序门 -> java -> j2se / 基础类



"java  -dfile.encoding=gbk class 中文字符串" 传入的中文string 显示部正确


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


"java -dfile.encoding=gbk class 中文字符串" 传入的中文string 显示部正确
发表于:2007-07-30 08:29:15 楼主
我的java程序:


 
---------------------------------------------------
 
import   java.io.*;
import   java.lang.string;

public   class   a
{

    public   static   void   main(   string[]   args   )
    {
         
try{
   
   
            string   wsurl   =   args[0].trim();    
            system.out.println(wsurl);
            system.out.println( "111 ");
            system.out.println( "文章 ");
            system.out.println( "222 ");
            printmultibyte(wsurl);
            system.out.println( " ");
            system.out.println( "333 ");
            printmultibyte( "文章4 ");
            system.out.println( " ");
            system.out.println( "444 ");
          }
         
catch   (exception   ex)
        {
            system.out.println( "\nexception   while   calling   web   service: ");
            ex.printstacktrace();
        }
     

    }    


        static   void   printmultibyte(   string   file   )
    {
         
        try   {
        string   str   =   file;
        bufferedwriter   stdout   =   new   bufferedwriter(new   outputstreamwriter(system.out, "gb2312 "));      
        stdout.write(str);
        stdout.flush();
        }
        catch   (java.io.ioexception     e)
        {
            system.out.println( "wrong ");
        }
    }    

}
--------------------------------------------------------
步骤:
在linux环境里,
javac   -encoding   gbk   a.java   (   or   java   a.java)
java   -dclient.encoding.override=gbk   -dfile.encoding=gbk   -duser.language=zh   -duser.region=cn     a   中
物拷锟斤拷
111
鏂囩珷
222
???
333
文章4
444
---------------------------------------------------------
问题:
为什么传入的中文字符串---中,   显示不正确?


快速检索

最新资讯
热门点击