📄 cfgmanager.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 + -