Here you can find the source of writeObject(File file, Object object)
public static void writeObject(File file, Object object) throws Exception
//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 void writeObject(String filename, Object object) throws Exception { writeObject(new File(filename), object); }//from www .j a v a 2s. c om public static void writeObject(File file, Object object) throws Exception { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file)); oos.writeObject(object); oos.flush(); oos.close(); } }