569
技术社区[云栖]
Properties读取文件缓存数据
private static Properties cache = new Properties();
static{
try {
cache.load(ConfigInfo.class.getClassLoader().getResourceAsStream("xxx.key"));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 获取指定key的值
* @param key
* @return
*/
public static String getValue(String key){
return cache.getProperty(key);
}
使用Properties函数,可以以key -value键值方式取出文件中的值。
最后更新:2017-04-02 16:47:52