configuration.java
来自「雷霆论坛是用J2EE技术开发的功能强大、扩展性强、易于定制」· Java 代码 · 共 49 行
JAVA
49 行
package lightningboard;
import java.util.Properties;
import java.io.InputStream;
import java.io.IOException;
/**
* LightningBoard configuration, configuration file:
* "/lightningboard.properties".
* @version 0.3.5
* @author Xiaobo Liu
*/
public class Configuration {
private Properties properties;
private final static Configuration cfg = new Configuration();
private Configuration() {
properties = new Properties();
InputStream is = null;
try {
is = getClass().getResourceAsStream("/lightningboard.properties");
properties.load(is);
} catch (Exception exception) {
System.out.println("Can't read the properties file. ");
} finally {
try {
if (is != null)
is.close();
} catch (IOException exception) {
// ignored
}
}
}
/**
* Use singleton pattern, only return one instance of Configuration.
* @return Configuration
*/
public static Configuration getInstance() {
return cfg;
}
/**
* Retun a value for certain key.
* @param key a certain key define in properties file.
* @return value
*/
public String getValue(String key) {
return properties.getProperty(key);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?