Here you can find the source of writeObject(File file, Object object)
public static void writeObject(File file, Object object)
//package com.java2s; /*// www .j ava2 s.c o m * Copyright 2016 janobono. All rights reserved. * Use of this source code is governed by a Apache 2.0 * license that can be found in the LICENSE file. */ import java.io.*; public class Main { public static void writeObject(File file, Object object) { try (ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(file))) { outputStream.writeObject(object); outputStream.flush(); } catch (IOException e) { throw new RuntimeException(e); } } }