Here you can find the source of writeObjectToFile(Object obj, File f)
public static boolean writeObjectToFile(Object obj, File f)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; public class Main { /**/*from w w w . j av a2 s. co m*/ * Writes a generic object to a file */ public static boolean writeObjectToFile(Object obj, File f) { try { FileOutputStream fout = new FileOutputStream(f); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(obj); oos.close(); } catch (Exception e) { System.out.println("Error writing Object to file: " + e.getMessage()); return false; } return true; } }