Here you can find the source of writeObject(Object obj, File path)
public static void writeObject(Object obj, File path)
//package com.java2s; //License from project: Open Source License import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static void writeObject(Object obj, File path) { ObjectOutputStream out = null; try {/*from ww w .j av a 2 s. c om*/ out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(path))); out.writeObject(obj); out.close(); } catch (IOException e) { System.err.println("Failed to write filename " + path); } finally { if (out != null) { try { out.close(); } catch (IOException e) { } } } } }