properties不支持中文,也不好改得支持中文.....这个类写的真是失败阿...
可以写个简单的...凑合用吧
package com.ap3g.Util;import java.io.*;import java.util.Hashtable;
import java.util.Map;public class Properties extends Hashtable<String,Object> { public Properties(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
} public Properties(int initialCapacity) {
super(initialCapacity);
} public Properties() {
super();
} public Properties(Map t) {
super(t);
}

public Properties(String path) {
super(); Load(path); }

public void Load(String path) {
File file=new File(path);
try {
FileInputStream fis = new FileInputStream(file); 
InputStreamReader isr = new InputStreamReader(fis, "GB2312"); 
BufferedReader in = new BufferedReader(isr);
String ln;
while((ln=in.readLine())!=null){
if (!ln.startsWith("#")){
int sep=ln.indexOf("=");
if (sep>0){
String key=ln.substring(0,sep).trim();
String value=ln.substring(sep+1).trim();
this.put(key,value);
}
}
}

} catch (Exception e) {
e.printStackTrace();
}  }
}

解决方案 »

  1.   

    如果你使用的eclipse,你可以下载一个propertyEditor的插件,这样,你就直接可以在properties中写中文了,他会帮你自动装换成ascii码。
      

  2.   

    timerri(),Spring中用ResourceBundleMessageSource类读取消息,而这个类用ResourceBundle读取消息,好像没用到Properties,我要怎么样才能用自定义的这个Properties类去替换呢?
      

  3.   

    谁说的properties不支持中文?!
    有没有看properties的实现?
    还有用过native2ascii命令没?
      

  4.   

    楼上的,properties类不支持中文,是人所共知的事,你看一下Properties类的源码就知道了,至于native2ascii只是转字符内码的一个工具而已。TO楼主:Properties这个类无论原文件是什么编码都会强制用iso8859-1编码来读的,
    源代码是:
     BufferedReader in = new BufferedReader(new InputStreamReader(inStream, "8859_1"));
    解决办法是,重载这个类的load方法,
    BufferedReader in = new BufferedReader(new InputStreamReader(inStream));
      

  5.   

    propertyEditor这个插件在哪能下到。给个地址吧
      

  6.   

    <target name="Native2ASCII">
    <native2ascii src="conf" dest="${classes.dir}" encoding="UTF-8" includes="*zh_CN.properties" />
    </target>
      

  7.   

    就是按照司令的方法,使用Native2ASCII转码成unicode