Here you can find the source of writeObject(File f, Object obj)
public static boolean writeObject(File f, Object obj)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static boolean writeObject(File f, Object obj) { boolean retObj = true; if (!f.getParentFile().isDirectory()) { f.getParentFile().mkdirs();//from w ww. j a v a 2 s . c o m } FileOutputStream fileOutputStream = null; ObjectOutputStream objectOutputStream = null; try { fileOutputStream = new FileOutputStream(f); objectOutputStream = new ObjectOutputStream(fileOutputStream); objectOutputStream.writeObject(obj); objectOutputStream.close(); } catch (IOException e) { retObj = false; } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { } } if (objectOutputStream != null) { try { objectOutputStream.close(); } catch (IOException e) { } } } return retObj; } }