ResourceBundle (读取properties文件及中文乱码解决方法)
2017-11-06 14:08
656 查看
原文: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时,进行编码转换
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
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
相关文章推荐
- ResourceBundle (读取properties文件及中文乱码解决方法)
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- java读取*.properties配置文件时,中文乱码解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Eclipse中properties文件读取时中文乱码、指定更新、写入中文变unicode码的解决方法
- Java读取properties配置文件时,中文乱码解决方法
- Android读取xxx.properties配置文件中文出现乱码解决方法
- java获得*.properties配置文件的值,解决读取中文时乱码的问题:
- Java读properties文件中文乱码问题的解决方法
- java读取properties配置文件时中文乱码解决办法
- Java读取properties文件中文乱码问题的解决
- Java读properties文件中文乱码问题的解决方法
- Java读取properties文件中文乱码问题解决
- C#读取中文文件出现乱码的解决方法
- 用c#读取文件内容中文是乱码的解决方法:
- Java读取properties文件中文乱码问题解决
- Android读取中文文件乱码解决方法