1.propertiesUtil工具类
2.程序中的用法
Properties properties = PropertiesUtil.getInstance();
InputStream memcachedIs = MemcacheService.class.getResourceAsStream("subCacheTime.properties");//memcacheService与subCacheTime.properties在同一个包里。
//也可以用这种方式 inputStream is = this.getClass().getClassLoader().getResourceAsStream("packageName/subCacheTime.properties");
int expiredTime=5000;
try {
properties.load(memcachedIs);
String expiredTimeString = (String)properties.get("expiredTime");
if(!"".equals(expiredTimeString)){
expiredTime = Integer.parseInt(expiredTimeString);
}
} catch (IOException e) {
e.printStackTrace();
}
阅读(902) | 评论(0) | 转发(0) |