📄 parseproperties.java
字号:
/**
*
*/
package com.xuntian.material.util;
import java.util.Enumeration;
import java.util.Properties;
import java.util.ResourceBundle;
/**
* @author lip Mar 7, 2006 copyright@xuntian
*/
public class ParseProperties {
/**
* file to properties
*/
private Properties properties;
/**
* 构造函数传递filename
*
* @param fileName
*/
public ParseProperties(String fileName) {
ResourceBundle config = ResourceBundle.getBundle(fileName);
Enumeration<String> keys = config.getKeys();
this.properties = new Properties();
while (keys.hasMoreElements()) {
String key = keys.nextElement();
this.properties.put(key, config.getString(key));
}
}
/**
* @param key
* @return the int value of the key
*/
public int getInt(String key) {
String temp = this.getString(key);
int value = 0;
if (temp.matches("[0-9]{1,10}")) {
value = Integer.parseInt(temp);
} else {
LogUtil.getLogger(this).error(
"DBConfig file:wrong values of the properties: " + temp);
}
return value;
}
/**
* @param key
* @return the string value
*/
public String getString(String key) {
return this.properties.getProperty(key);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -