protected void save() { String location = directory + "/" + name + ".txt"; BufferedWriter writer = null; try { // log.info("Saving " + location); writer = new BufferedWriter(new FileWriter(location)); writer.write("# " + location); writer.newLine(); // log.info("categories size " + categories.size()); Iterator<String> catIter = categories.keySet().iterator(); while (catIter.hasNext()) { String catName = catIter.next(); // log.info(catName); Category cat = categories.get(catName); Iterator<String> statIter = cat.iterator(); while (statIter.hasNext()) { String statName = statIter.next(); String line = catName + ":" + statName + ":" + cat.get(statName); writer.write(line); writer.newLine(); } } } catch (IOException ex) { log.log(Level.SEVERE, "Exception while creating " + location, ex); } finally { try { if (writer != null) { writer.close(); } } catch (IOException ex) { log.log(Level.SEVERE, "Exception while closing " + location, ex); } } }