property工具类
来源:互联网 发布:mirna数据库 编辑:程序博客网 时间:2024/06/16 16:38
public final class PropertiesInfoHelper {
private static final Logger logger = LoggerFactory.getLogger(PropertiesInfoHelper.class);
private static ClassLoader classLoader = PropertiesInfoHelper.class.getClassLoader();
public final static Properties SYSCONFIG = readPropertiesFile("props/sysConfig.properties");
public final static Properties IDCONFIG = readPropertiesFile("props/idConfig.properties");
/**
* 在class路径下读取文件
*
* @param clazzPathFile
* @return
*/
private static Properties readPropertiesFile(String clazzPathFile) {
Properties properties = new Properties();
InputStreamReader is = null;
try {
is = new InputStreamReader(classLoader.getResourceAsStream(clazzPathFile), "UTF-8");
properties.load(is);
} catch (Exception e) {
logger.error("Load properties file" + clazzPathFile + ", exception" + e.getMessage());
new RuntimeException("Load properties file" + clazzPathFile, e);
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
logger.info("Close file exception, " + e.getMessage());
}
}
return properties;
}
private static final Logger logger = LoggerFactory.getLogger(PropertiesInfoHelper.class);
private static ClassLoader classLoader = PropertiesInfoHelper.class.getClassLoader();
public final static Properties SYSCONFIG = readPropertiesFile("props/sysConfig.properties");
public final static Properties IDCONFIG = readPropertiesFile("props/idConfig.properties");
/**
* 在class路径下读取文件
*
* @param clazzPathFile
* @return
*/
private static Properties readPropertiesFile(String clazzPathFile) {
Properties properties = new Properties();
InputStreamReader is = null;
try {
is = new InputStreamReader(classLoader.getResourceAsStream(clazzPathFile), "UTF-8");
properties.load(is);
} catch (Exception e) {
logger.error("Load properties file" + clazzPathFile + ", exception" + e.getMessage());
new RuntimeException("Load properties file" + clazzPathFile, e);
} finally {
if (is != null)
try {
is.close();
} catch (IOException e) {
logger.info("Close file exception, " + e.getMessage());
}
}
return properties;
}
}
使用:
PropertiesInfoHelper.IDCONFIG.getProperty("aaaal")
0 0
- property工具类
- property配置文件读取工具类
- 根据key获取property文件中的值工具类
- property文件到vo对象的映射工具类
- property
- property
- Property
- @property
- @property
- property
- @property(..,..)
- property
- @property
- property
- property
- @property
- property()
- @property
- java.lang.OutOfMemoryError: PermGen space解决方法
- JavaScript 的关键字和保留字大全
- 网页导航title显示logo小图标的写法
- 延展操作符和解构的简单实际应用
- hdu 2036(多边形面积公式)
- property工具类
- Android WebView POST请求详解
- 根据时间戳获取剩余时间,并显示时分秒格式
- linux下clock计时为0的问题?
- LuceneInAction-近实时搜索
- python 使用Boost.python 调用c++
- Linux内核-内存-伙伴系统算法
- java:多线程的使用(一)
- PAT-1001. A+B Format (20)