首页 > 其他 > 详细

类初始化的时候就加载properties文件中的属性值

时间:2015-02-28 14:36:26      阅读:381      评论:0      收藏:0      [点我收藏+]
private static final String RULESUBMITSERVLETURL;
private static final String CALLSUBMITSERVLETURL;
static {
Properties props = new Properties();
String fileName = "sunshineserver.properties";
InputStream in = RuleDealJob.class.getClassLoader()
.getResourceAsStream(fileName);
if (in != null) {
try {
props.load(in);
RULESUBMITSERVLETURL = props.getProperty("sunshine.url")
+ props.getProperty("sunshine.ruleSubmit");
CALLSUBMITSERVLETURL = props.getProperty("sunshine.url")
+ props.getProperty("sunshine.callBackSubmit");
} catch (IOException e) {
throw new RuntimeException(
"读取接口工程地址文件失败,请确认classpath下存在intfserver.properties,"
+ e.getMessage(), e);
}finally{
if(in!=null){
try {
in.close();
} catch (IOException e) {
}
}
}
} else {
RULESUBMITSERVLETURL = "";
CALLSUBMITSERVLETURL = "";
}

类初始化的时候就加载properties文件中的属性值

原文:http://blog.csdn.net/wangyonglin1123/article/details/43984943

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!