Java读取properties文件 中文乱码问题

在读取java properties文件的时候如果value是中文,会出现读取乱码的问题
开始以为是文件保存编码问题,把eclipse中所有的文件编码都修改成utf8,不行,把内容复制到notepad++进行utf8编码转换,还是不行,网上查资料发现其用的是字节流来读取文件,具体代码如下:
Properties p=new Properties();
InputStream is=new FileInputStream(new File(""));
p.load(is);

如果使用字符流的话 就可以了

Properties p=new Properties();
BufferedReader b=new BufferedReader(new InputStreamReader(new FileInputStream(new File(""))))
p.load(b);


猜你喜欢

转载自blog.csdn.net/zou79189747/article/details/42168495