Here you can find the source of serialize(Serializable s, File dir, String fileName)
public static void serialize(Serializable s, File dir, String fileName) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { public static void serialize(Serializable s, File dir, String fileName) throws FileNotFoundException, IOException { new ObjectOutputStream(new FileOutputStream(dir.getPath() + File.separator + fileName)).writeObject(s); }//from ww w .j a v a2 s . com }