public class ConfigReader {
private static Properties config = new Properties();//基本配置
private static Log log =LogUtils.getBaseLog();
/**
* 加载配置文件
*/
static {
InputStream in1 = null;
try {
ClassLoader loader = ConfigReader.class.getClassLoader();
in1 = loader.getResourceAsStream("/config/base.properties");
config.load(in1);
} catch (Exception e) {
log.error("加载配置文件失败", e);
} finally {
CloseUtil.closeInputStream(in1);
}
}
/**
* 根据key读取基本配置信息
* @param object
* @return
*/
public static String getProperty(String object){
return config.getProperty(object);
}
}
java 读取配置文件
最新推荐文章于 2024-07-24 00:04:57 发布