读取配置文件
2015-08-03 13:41
405 查看
public class ReadConfig { public static Properties dbproperties = new Properties(); private static Logger logger = Logger.getLogger(ReadConfig.class); static { loadsProperties(); } static public void loadsProperties(){ InputStream is = ReadConfig.class.getResourceAsStream("/parameters.properties"); try { dbproperties.load(is); } catch (Exception e) { logger.error("不能读取属性文件. ", e); } } }
该例子中,配置文件parameters.properties存在于src目录下
调用:
String myBlogName = ReadConfig.dbproperties.getProperty("hqq1007")
相关文章推荐
- 微信开发总结 五
- mysql : Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf16_general_ci,IMPLICIT) for operation '
- 网页在地址栏和收藏夹中图标显示效果
- 详解SHOW PROCESSLIST显示哪些线程正在运行列出的状态
- 如何手动解析CrashLog
- [深入理解Android卷二 全文-第四章]深入理解PackageManagerService
- add_header X-Frame-Options "SAMEORIGIN";NGINX
- AudioManager的简单使用
- MD5加密
- 微信开发总结 四
- IIFE (Imdiately Invoked Function Expression 立即执行的函数表达式)。
- spring和mybatis整合进行事务管理
- Android开发问题集合
- leetcode 66: Plus One
- Bus System
- Scikit-Learn:开源的机器学习Python模块
- poj 3041 构图+最小点覆盖
- maven 在 mac中的配置
- Linux下快速安装Mysql及使用
- 网络路由设计基础