⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 propertyconfig.java

📁 java阿里巴巴代码
💻 JAVA
字号:
/**
 * @(#) PropertyConfig.java
 * @Author Alex Lee
 * @version 1.0.1
 */

package tools.util;

import java.io.InputStream;
import java.util.Properties;

public class PropertyConfig
{
	static private PropertyConfig _config = null;
	static private Properties dbProps = null;
	static protected PropertyConfig getInstance(String filename)
	{
		if(_config==null)
			_config = new PropertyConfig(filename);
		return _config;
	}

	protected PropertyConfig(String filename)
	{
		InputStream is = getClass().getClassLoader().getResourceAsStream(filename);
		dbProps = new Properties();
		try {
		    dbProps.load(is);
		}
		catch (Exception e) {
		    System.err.println("Can't read the properties file. " +
				"Make sure " + filename + " is in the CLASSPATH");
		    return;
		}
	}
	
	public static String getProperty(String filename, String prop)
	{
		return getProperty(filename, prop, null);
	}

	public static String getProperty(String filename, String prop, String defval)
	{
		getInstance(filename);
		if (dbProps == null)
			return defval;
		
		return dbProps.getProperty(prop, defval);
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -