读取配置文件properties工具类
package com.cmsz.rc.util;
import java.text.MessageFormat;
import java.util.Properties;
public class ConfigReaderUtil {
/**
* 配置属性
*/
private static Properties properties;
public static String getProperties(String key) {
String tempStr = String.valueOf(properties.get(key));
if (null != tempStr && !tempStr.isEmpty()) {
return tempStr;
} else {
return "";
}
}
public static String getProperties(String key, Object... strs) {
String tempStr = String.valueOf(properties.get(key));
if (null != tempStr && !tempStr.isEmpty()) {
if (strs != null && strs.length > 0) {
return MessageFormat.format(tempStr, (Object[]) strs);
} else {
return tempStr;
}
} else {
return "";
}
}
public static Properties getProperties() {
return properties;
}
public static void setProperties(Properties properties) {
ConfigReaderUtil.properties = properties;
}
/**
* 私有的构造函数
*/
private ConfigReaderUtil() {
}
}
还没有评论,来说两句吧...