Here you can find the source of saveFile(Object o, String filename)
public static boolean saveFile(Object o, String filename)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static final String DATA_DIR = "data/"; public static boolean saveFile(Object o, String filename) { FileOutputStream fos = null; ObjectOutputStream oos = null; boolean success = false; try {/* ww w . j a v a 2s .co m*/ fos = new FileOutputStream(DATA_DIR + filename); oos = new ObjectOutputStream(fos); oos.writeObject(o); success = true; } catch (IOException e) { e.printStackTrace(); success = false; } finally { try { oos.close(); } catch (IOException e) { e.printStackTrace(); success = false; } } return success; } }