Home > Java > javaTutorial > Solution to the problem of Chinese garbled characters when Java reads the properties configuration file

Solution to the problem of Chinese garbled characters when Java reads the properties configuration file

高洛峰
Release: 2017-01-12 10:30:33
Original
1697 people have browsed it

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;
  }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template