Java读取properties配置文件时,出现中文乱码的解决方法
发布时间:2020-12-14 14:45:15 所属栏目:Java 来源:网络整理
导读:如下所示: public static String getConfig(String key) { Properties pros = new Properties(); String value = ""; try { pros.load(new InputStreamReader(Object.class.getResourceAsStream("/properties.properties"),"UTF-8")); value = pros.get(key
如下所示: public static String getConfig(String key) { Properties pros = new Properties(); String value = ""; try { pros.load(new InputStreamReader(Object.class.getResourceAsStream("/properties.properties"),"UTF-8")); value = pros.get(key).toString(); } catch (IOException e) { log.error(e.getMessage()); } return value; } 以上就是小编为大家带来的Java读取properties配置文件时,出现中文乱码的解决方法全部内容了,希望大家多多支持编程小技巧~ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |