package com.autohome.common;
import java.io.*;
import java.util.Properties;
public class PropertyUtil {
private static Properties props;
private static void loadProps() {
props = new Properties();
InputStream in = null;
try {
in = PropertyUtil.class.getClassLoader().getResourceAsStream("Config.properties");
props.load(in);
} catch (FileNotFoundException e) {
} catch (IOException e) {
} finally {
try {
if (null != in) {
in.close();
}
} catch (IOException e) {
}
}
}
public static String getProperty(String key) {
if (null == props) {
loadProps();
}
return props.getProperty(key);
}
public static String getProperty(String key, String defaultValue) {
if (null == props) {
loadProps();
}
return props.getProperty(key, defaultValue);
}
}
spring mvc 动态读配置文件
最新推荐文章于 2023-09-02 18:17:01 发布