java读取.properties文件乱码

1.config.properties文件写不进中文,写进去都变成了unicode,解决的方法是右键该文件——Properties——Resource——Text file encoding ,选other,我将other改为了UTF-8,这样能够写进去中文,可是读取时又变成乱码了。

2,解决读取乱码:

String  content = new String(PropertiesConfig.getProperty("mail.content").getBytes("ISO8859-1"), "utf-8");

这样就能够读出中文。
posted on 2015-02-11 11:38  gcczhongduan  阅读(106)  评论(0编辑  收藏  举报