浏览 2133 次
锁定老帖子 主题:Java读取properties文件
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2009-06-10
package com.configuration; import java.util.ResourceBundle; public class Configuration { private static Configuration configuration = null; private static ResourceBundle resourceBundle = null; private static final String CONFIG_FILE = "config"; private Configuration() { resourceBundle = ResourceBundle.getBundle(CONFIG_FILE); } public synchronized static Configuration getInstance() { if (null == configuration) { configuration = new Configuration(); } return (configuration); } public String getValue(String key) { return (resourceBundle.getString(key)); } }
config.propeties
driverClassName=oracle.jdbc.driver.OracleDriver url=jdbc:oracle:thin:@127.0.0.1:1521:ORADB9 username=tiger password=123
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |