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

📄 defaultproperty.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.util.property;

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

/**
 * The default property.
 */
public class DefaultProperty {
	private static Properties prop = null;

    /**
     * Initialize the proerties
     * @throws Exception
     */
    private static void init() throws Exception{
	    if (prop == null)
            prop = new Properties();

	    InputStream is = DefaultProperty.class.getClassLoader()
                .getResourceAsStream("myapp.properties");
	    prop.load(is);
	}

	/**
	 * Get the property value
	 * @param key The property key 
	 * @param defaultValue The default value.
	 * @return The Property value. 
	 * @throws Exception
	 */
	public static String getProperty(String key, String defaultValue) throws Exception{
		if (prop == null) {
			init();
		}
		return prop.getProperty(key, defaultValue);
	}
	
	/**
	 * Get the property value
	 * @param key The property key 
	 * @return The Property value. 
	 * @throws Exception
	 */
	public static String getProperty(String key) throws Exception{
		return getProperty(key, null);
	}
    
} 

⌨️ 快捷键说明

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