原文: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");
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