Here you can find the source of writeObject(Object o, File path)
public static void writeObject(Object o, File path)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.ObjectOutputStream; public class Main { public static void writeObject(Object o, File path) { try {//ww w. j a va 2 s . com ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(path)); try { out.writeObject(o); } finally { out.close(); } } catch (Exception e) { throw new RuntimeException(e); } } }