Java读取properties配置文件的几种方式
1 前言
原文链接
2 基于ClassLoader读取配置文件
该方式只能读取类路径下的配置文件,有局限但是如果配置文件在类路径下比较方便。
Properties properties = new Properties();
// 使用ClassLoader加载properties配置文件生成对应的输入流
InputStream in = PropertiesMain.class.getClassLoader().getResourceAsStream("config/config.properties
转载
2021-05-17 16:34:24 ·
254 阅读 ·
0 评论