Here you can find the source of saveData(HashMap data, String filename)
@SuppressWarnings("rawtypes") public static void saveData(HashMap data, String filename)
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.util.HashMap; public class Main { @SuppressWarnings("rawtypes") public static void saveData(HashMap data, String filename) { try {/*from ww w .j a v a 2 s . co m*/ writeObject(data, filename); } catch (IOException e) { e.printStackTrace(); } } private static void writeObject(Object data, String filename) throws IOException { File file = new File(filename); if (!file.exists()) { file.getParentFile().mkdirs(); file.createNewFile(); } FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(data); out.close(); fileOut.close(); } }