原文:http://blog.csdn.net/joecheungdishuiya/article/details/6304993
public class test {
static ResourceBundle rsb;
/**
* @param args
* @throws UnsupportedEncodingException
*/
public static void main(String[] args) throws UnsupportedEncodingException {
// TODO Auto-generated method stub
rsb=ResourceBundle.getBundle("address_all");
String keyValue = new String(rsb.getString("chainsaveservlet.save").getBytes("ISO-8859-1"), "GBK");
System.out.println(keyValue);
}
}
中文乱码解决
1.解决方法一:在使用keyValue时,进行编码转换
String keyValue = new String(rb.getString(keyName).getBytes("ISO-8859-1"), "GBK");
String keyValue = new String(rb.getString(keyName).getBytes("ISO-8859-1"), "GBK");
2.解决方法二:将machine_zh_CN.properties转换成为unicode形式
native2ascii.exe machine_zh_CN.properties machine_zh_CN.txt
p1=/u51b0/u7bb1 p2=/u6d17/u8863/u673a p3=/u7535/u89c6/u673a