Here you can find the source of serialize(Serializable obj, ByteArrayOutputStream bout)
public static void serialize(Serializable obj, ByteArrayOutputStream bout)
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import java.io.Serializable; public class Main { /** Serialize the given object into the given stream */ public static void serialize(Serializable obj, ByteArrayOutputStream bout) { try {/*from ww w . j a va 2s. c o m*/ ObjectOutputStream out = new ObjectOutputStream(bout); out.writeObject(obj); out.close(); } catch (IOException e) { throw new IllegalStateException("Could not serialize " + obj, e); } } }