Java读取properties文件工具类

水深无声 2023-05-29 11:39 155阅读 0赞
  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.util.Properties;
  4. public class PropertiesUtil {
  5. /**
  6. * 根据配置文件名称,返回Properties对象
  7. * properties.getProperty("ip").trim()
  8. * @return Properties
  9. * @throws IOException
  10. */
  11. public static Properties readProperties(String propertiesName) throws IOException{
  12. //读取properties配置文件
  13. Properties properties = new Properties();
  14. InputStream is = PropertiesUtil.class.getClassLoader().getResourceAsStream(propertiesName);//new BufferedInputStream(new FileInputStream("./conf/pue_conf.properties"));
  15. properties.load(is);
  16. return properties;
  17. }
  18. }

发表评论

表情:
评论列表 (有 0 条评论,155人围观)

还没有评论,来说两句吧...

相关阅读