pps.put("file.encoding","ISO-8859-1");
String str=new String("周".getBytes());
System.out.print(str.length());
System.out.println(str);
    byte[] b=str.getBytes("GBK");
   String strGBK=new String(b); 
      System.out.println(strGBK);输出如下:
1周

就是说pps.put("file.encoding","ISO-8859-1");这个设置没起作用。

解决方案 »

  1.   

    Properties pps=System.getProperties();
      

  2.   

    用System.getProperties中所得到的属性,是你安装JDK的时候根据你的操作系统的情况生成的(i guess and i am optimistic about my odds),每次你取的时候都是根据这个文件(或者注册表)取得的,你的put方法只是表示你要把一个key-value对加入到一个HashTable中,并没有更改那个文件(或者注册表)的内容。
    你所要达到的效果,应该是javac 的时候指定enconding
    JF