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();
}
}