properties文件中文乱码解决

来源:互联网 发布:冷库负荷计算软件 编辑:程序博客网 时间:2024/05/30 22:52

excel.properties 如下:

学号=id



Properties prop = new Properties();InputStream inStream = Test.class.getClassLoader().getResourceAsStream("excel.properties");prop.load(inStream);String str = new String("学号".getBytes(),"ISO8859-1");System.out.println(new String(prop.getProperty(str).getBytes("iso8859-1"),"UTF-8"));

总结:在properties文件中保存的是iso8859-1的编码格式,要显示可以将其转化为UTF-8的编码。

0 0