Here you can find the source of saveCache()
public static boolean saveCache()
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; import java.util.Iterator; import java.util.Map; public class Main { private static Map<String, Integer> cache; public static boolean saveCache() { String data = ""; Iterator<String> keyIterator = cache.keySet().iterator(); while (keyIterator.hasNext()) { String key = (String) keyIterator.next(); int value = cache.get(key); data += key + "," + value + "\n"; }/*from ww w. java 2s . c o m*/ File f = new File("cache.map"); if (f.exists()) f.delete(); try (FileOutputStream fo = new FileOutputStream(f); OutputStreamWriter out = new OutputStreamWriter(fo, "UTF-8")) { out.write(data); out.flush(); return true; } catch (Exception e) { System.err.println(e); return false; } } }