Here you can find the source of writeObject(File file, Object object)
public static void writeObject(File file, Object object)
//package com.java2s; /*// w ww . j ava2s . c om * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static void writeObject(File file, Object object) { try { FileOutputStream fileOut = new FileOutputStream(file); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(object); out.close(); fileOut.close(); } catch (IOException e) { e.printStackTrace(); } } }