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时,进行编码转换
view plaincopy to clipboardprint?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
*参考资料*
1.http://hi.baidu.com/btb368/blog/item/3537221e5af536daa78669a8.html