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

📄 cfgmanager.java

📁 旅游自助系统
💻 JAVA
字号:
/**
 * 
 */
package org.tshs.core;

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

/**
 * Class for reading the Tshs system configuration. The main configuration is
 * read in as properties from a standard properties file via this class.
 * 
 * @author Administrator
 *
 */
public class CfgManager {
	
	private static Properties properties;
	
	private static void loadConfig(String cfgPath){		
		if(properties != null){
			return;
		}
		
		if(cfgPath == null){
			InputStream in = CfgManager.class.getResourceAsStream("/tshs.cfg");
			if(in == null){
				// throw some exception;
				return;
			}
			try {
				properties = new Properties();
				properties.load(in);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public static String getProperty(String key){
		
		if(properties == null){
			loadConfig(null);
		}
		
		return properties.getProperty(key);
	}
	
	public static int getIntProperty(String key){
		if(properties == null){
			loadConfig(null);
		}
		String s = properties.getProperty(key);
		return Integer.parseInt(s);
	}

	/**
	 * @param string
	 * @return
	 */
	public static Long getLongProperty(String key) {
		if(properties == null){
			loadConfig(null);
		}
		String s = properties.getProperty(key);
		return Long.parseLong(s);
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}

⌨️ 快捷键说明

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