`

读取配置的又一种读法

阅读更多

/**

 * 读取配置文件

 *

 */

public class ConfigInfo {

private static Properties cache1 = new Properties();

static{

try {

cache1.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);

}

private static ResourceBundle cache = null;

static{

cache = ResourceBundle.getBundle("merchantInfo");

}

public static String getValue(String key){

return cache.getString(key);

}

}


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics