java获得*.properties配置文件的值,解决读取中文时乱码的问题:

java获得*.properties配置文件的值,解决读取中文时乱码的问题:

  String content = "";
  //使用io流读取,解决中文乱码

  Properties properties = new Properties();
  InputStream inputStream = this.getClass().getResourceAsStream("/smsmessage.properties");
  BufferedReader bf = new BufferedReader(new  InputStreamReader(inputStream, "UTF-8"));
  properties.load(bf);
  content = properties.getProperty(contentProperty);// 获取预先配置的内容 ,contentProperty是配置文件里对应的标识名

你可能感兴趣的:(java,中文,乱码,解决读取中文时乱码的问题)