Here you can find the source of write(Object obj, String filePath)
public static void write(Object obj, String filePath) throws IOException
//package com.java2s; import java.io.IOException; import java.io.ObjectOutputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void write(Object obj, String filePath) throws IOException { Path path = Paths.get(filePath); try (ObjectOutputStream output = new ObjectOutputStream(Files.newOutputStream(path))) { output.writeObject(obj);/*from w w w . j a v a 2s .c o m*/ } } }