Here you can find the source of writeObjectToFile(String fileName, Object obj)
public static boolean writeObjectToFile(String fileName, Object obj)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; public class Main { public static boolean writeObjectToFile(String fileName, Object obj) { try {/*w w w.j a va 2 s .c o m*/ File f = new File(fileName); f.setWritable(true); FileOutputStream fout = new FileOutputStream(f); ObjectOutputStream oo = new ObjectOutputStream(fout); oo.writeObject(obj); fout.close(); return true; } catch (Exception ex) { return false; } } }