Here you can find the source of serializeToFile(Object obj, String fileName)
public static void serializeToFile(Object obj, String fileName) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static void serializeToFile(Object obj, String fileName) throws IOException { ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(fileName))); out.writeObject(obj);//from www. j av a2 s .com out.close(); } }