package com.epay.utils;
import java.util.Properties;
/**
* 读取配置文件
*
*/
public class ConfigInfo {
/** 静态缓存只加载一次 */
private static Properties cache = new Properties();
static{
try {
cache.load(ConfigInfo.class.getClassLoader().getResourceAsStream("merchantInfo.properties"));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取指定key的值
* @param key
* @return
*/
public static String getValue(String key){
return cache.getProperty(key);
}
}
加载配置文件: