直接上代码
Properties pros = new Properties();
String value = "";
try{
//读取属性文件a.properties
InputStream in =
new BufferedInputStream(new FileInputStream("a.properties"));
pros.load(in); ///加载属性列表
Iterator<String> it=pros.stringPropertyNames().iterator();
while(it.hasNext()){
String key=it.next();
String sx=pros.getProperty(key);
sx=new String(sx.getBytes("ISO-8859-1"),"UTF-8");
}
in.close();
}
catch(Exception e){
System.out.println(e);
}
sx=new String(sx.getBytes(“ISO-8859-1”),”UTF-8”);
其中”ISO-8859-1”是你编译工具properties的文件编码,后面的“UTF-8”是需要输出的编码