use of org.apache.commons.configuration2.event.ConfigurationEvent in project winery by eclipse.
the class AutoSaveListener method onEvent.
@Override
public void onEvent(ConfigurationEvent event) {
if (!event.isBeforeUpdate()) {
try {
if (!Files.exists(this.path.getParent())) {
Files.createDirectories(this.path.getParent());
}
} catch (IOException ce) {
LOGGER.error("Could not update properties file", ce);
return;
}
try (OutputStream out = Files.newOutputStream(this.path, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING)) {
OutputStreamWriter writer = new OutputStreamWriter(out);
this.configuration.write(writer);
} catch (ConfigurationException | IOException ce) {
LOGGER.error("Could not update properties file", ce);
}
}
}
Aggregations