Properties 工具类
package cn.qiu;
import java.io.IOException;
import java.util.Properties;
/**
* Properties 工具类
* @author QiuRiMangCao
*
*/
public class PropertiesConfigUtils {
private static Properties prop = null;
static {
prop = new Properties();
try {
// 从类路径下读取属性文件
prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("properties_config.properties"));
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getProperty(String keyName) {
return prop.getProperty(keyName);
}
public static String getProperty(String keyName, String defaultValue) {
return prop.getProperty(keyName, defaultValue);
}
}