When Java reads the properties configuration file the Chinese garble appears

  • 2020-05-16 06:55:27
  • OfStack

As follows:


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;
  }

Related articles: