java getstringarray_Java PropertiesConfiguration.getStringArray方法代码示例

import org.apache.commons.configuration.PropertiesConfiguration; //导入方法依赖的package包/类

public void recordInit(String[] args) throws Exception {

/*

* FileOutputStream out = new FileOutputStream(Enterence.propFileName);

* Enterence.prop.putIfAbsent("sudoers", Enterence.sudoers);

* Enterence.prop.putIfAbsent("sudoPwd", Enterence.sudoPwd);

* Enterence.prop.putIfAbsent("server", Enterence.server);

* Enterence.prop.putIfAbsent("name", Enterence.name);

* Enterence.prop.putIfAbsent("channels", Enterence.channels);

* Enterence.prop.putIfAbsent("preffix", Enterence.preffix);

* Enterence.prop.putIfAbsent("sudoers", Enterence.sudoers);

* Enterence.prop.store(out, null); out.close();

*/

if (file.exists()) {

Gui.log("Record file found, start loading");

try {

PropertiesConfiguration config = new PropertiesConfiguration(

Configs.recordFileName);

Records.verifiedUsers.addAll(Arrays.asList(config

.getStringArray("verifiedUsers")));

Records.mutedUsers.addAll(Arrays.asList(config

.getStringArray("mutedUsers")));

// Records.records = (HashMap>)

// config.getProperty("records");

String[] usrEntries = config.getStringArray("usrEntries");

Gui.log("Users Read:" + usrEntries.toString());

for (String usr : usrEntries) {// per usr

//Gui.log("loading:" + usr);

String[] statements = config.getStringArray(usr);

HashSet statementsMap = new HashSet();

for (String statement : statements) {// per statement

//Gui.log(" loading:" + statement);

statementsMap.add(statement);

}

Records.records.put(usr, statementsMap);

Gui.log("Record successfully loaded");

}

if (Records.verifiedUsers == null || Records.mutedUsers == null

| Records.records == null) {

throw new Exception("File damaged");

}

} catch (Exception e) {

// Gui.displayException(e);

Gui.log("Record file error: " + e.getMessage()

+ ", creating one as default");

createDefault();

}

} else {

Gui.log("Record file not found, creating one as default");

createDefault();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值