介绍:加载指定配置文件,并提供获取配置参数值的方法
public final class PropertiesUtil {
private static String urlPrefix = "";
static {
Properties prop = new Properties();
InputStream in = PropertiesUtil.class.getClassLoader()
.getResourceAsStream("DataCenterUrl.properties");
try {
prop.load(in);
urlPrefix = prop.getProperty("dataUrlPrefix");
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != in) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
public static String getUrlPrefix() {
return urlPrefix;
}
}