首页 > 开发 > Java > 正文

Java读取properties配置文件时,出现中文乱码的解决方法

2024-07-13 10:01:26
字体:
来源:转载
供稿:网友

如下所示:

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配置文件时,出现中文乱码的解决方法全部内容了,希望大家多多支持VeVb武林网~


注:相关教程知识阅读请移步到JAVA教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表