论坛首页 入门技术论坛

Java读取properties文件

浏览 2133 次
精华帖 (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

 

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics