如下所示:
1
2
3
4
5
6
7
8
9
10
11
|
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; } |
以上就是小編為大家?guī)?lái)的Java讀取properties配置文件時(shí),出現(xiàn)中文亂碼的解決方法全部?jī)?nèi)容了,希望大家多多支持服務(wù)器之家~