Here you can find the source of saveObjectToFile(File file, Object object)
public static boolean saveObjectToFile(File file, Object object)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { public static boolean saveObjectToFile(File file, Object object) { ObjectOutputStream os = null; try {//from w ww . j a v a 2s .c o m os = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(file))); os.writeObject(object); return true; } catch (Exception e) { e.printStackTrace(); } finally { safeClose(os); } return false; } public static void safeClose(Closeable os) { if (os != null) { try { os.close(); } catch (IOException e) { e.printStackTrace(); } } } }