Here you can find the source of saveMap(Map
public static <K, V> void saveMap(Map<K, V> map, String filePath)
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Map; import java.util.Map.Entry; public class Main { public static <K, V> void saveMap(Map<K, V> map, String filePath) { PrintWriter pw = null;//from ww w . j av a2 s . co m try { pw = new PrintWriter(new BufferedWriter(new FileWriter(filePath)), true); } catch (IOException e) { e.printStackTrace(); exit(1); } for (Entry<K, V> entry : map.entrySet()) { pw.print(entry.getKey()); pw.print('\t'); pw.println(entry.getValue()); } pw.close(); } public static void exit(int status) { System.exit(status); } }