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