Here you can find the source of serializeToFile(Serializable s, String path)
public static void serializeToFile(Serializable s, String path) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; import java.io.Serializable; public class Main { public static void serializeToFile(Serializable s, String path) throws IOException { FileOutputStream fileOut = new FileOutputStream(path); serialize(s, fileOut);/*from w ww . j a v a2s.c o m*/ fileOut.close(); } public static void serialize(Serializable s, OutputStream os) throws IOException { ObjectOutputStream out = new ObjectOutputStream(os); out.writeObject(s); out.close(); } }