/**
* 加载Properties文件
* @param path Properties文件路径
* @return
*/
private static Properties getClasspathProperties(String path) {
Assert.notNull(path);
InputStream in = null;
try {
File file = new File(SysUtils.class.getResource("/").getPath() + path);
in = new FileInputStream(file); Properties properties = new Properties();
properties.load(in); return properties;
} catch (IOException e) {
throw new SysException("无法读取资源文件:[{}],错误信息:{}", path, e.getMessage());
} finally {
if (null != in) {
try {
in.close();
} catch (IOException e) {
throw new SysException("无法读取资源文件:[{}],错误信息:{}", path, e.getMessage());
}
}
}
}
/**
* 获取Properties中key对应的value值
* @param properties Properties
* @param key 键
* @param defaultValue 默认值
* @return
*/
private static String getProperty(Properties properties, String key, String defaultValue) {
Assert.notNull(properties);
Assert.hasLength(key);
String value = null;
if (properties.containsKey(key)) {
value = properties.getProperty(key);
} else {
LOG.info("未发现配置:" + key);
} if (StringUtils.isBlank(value)) {
value = defaultValue;
}
LOG.debug("获取到值为{}",value);
return value;
}

最新文章

  1. 头文件 string.h cstring string 区别
  2. MYSQL例题合集
  3. HTML5就是现在:深入了解Polyfills
  4. HDU 1158 Employment Planning【DP】
  5. FormsAuthentication与Session超时时间不一的解决方法
  6. win8 64位系统,安装JDK的步骤及其环境配置
  7. EF-CodeFirst-表关系-延迟/贪婪加载
  8. Flex中如何通过horizontalTickAligned和verticalTickAligned样式指定线图LineChart横竖方向轴心标记的例子
  9. J2SE知识点摘记(二十四)
  10. SSD常见问题的技术分析
  11. openwrt通过libcurl上传图片,服务器端通过PHP接收文件
  12. 使用MFC创建C++程序
  13. ue4 材质表达式分类
  14. js获取数组中相同元素数量
  15. Go语言执行流程
  16. springsession 实现session 共享
  17. Android 支付密码输入框,自定义EditText实现密码输入框功能;
  18. FOJ-1058-粗心的物理学家
  19. 用Python实现多站点运维监控
  20. 2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6153 A Secret KMP,思维

热门文章

  1. 读书笔记——《C++ Concurrency IN ACTION》
  2. As a Start - 毫厘之间,宇宙之外
  3. Mysql执行计划说明
  4. 2.supervisor实时监控程序存活状态
  5. python-虎扑爬虫
  6. zabbix自动清理30天前的数据
  7. Servlet--Servlet接口
  8. k8s 如何 Failover?- 每天5分钟玩转 Docker 容器技术(127)
  9. LINUX读写文件区别
  10. Docker最佳实践-部署LNMP环境