Home >Java >javaTutorial >Solution to the problem of Chinese garbled characters when Java reads the properties configuration file
As shown below:
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; }
The above is the solution to the problem of Chinese garbled characters when Java reads the properties configuration file brought by the editor. I hope you will use it. Support PHP Chinese website~
For more solutions to the problem of Chinese garbled characters when Java reads the properties configuration file, please pay attention to the PHP Chinese website for related articles!