/** * Save this INI to the file from which it was loaded. * @throws IOException */ public void save() throws IOException { assert configFile != null; assert charset != null; if (configFile != null && charset != null) { save(configFile, charset); } }
/** * Save the INI to a file using the given encoding. * * @param file the file to load * @param encoding the encoding of the file * @throws IOException */ public void save(File file, String encoding) throws IOException { this.configFile = file; this.charset = encoding; Writer out = null; try { out = new OutputStreamWriter(new FileOutputStream(file), encoding); save(out); } finally { if (out != null) { out.close(); out = null; } } }
/** * Output the Ini to the given Writer. * * @param out the Writer to which this Ini should be written */ private void save(Writer out) { PrintWriter writer = null; if (out instanceof PrintWriter) { writer = (PrintWriter) out; } else { writer = new PrintWriter(out); } for (String sectionName : list) { IniSection section = doGetSection(sectionName); section.save(writer); } }
config.replace(key, value); try { config.save(new File(writeLocation, bookConf), getBookCharset()); } catch (IOException ex) { LOGGER.error("Unable to save {}={}: conf file for [{}]; error={}", key, value, configAll.getName(), ex);