Java tutorial
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.ObjectOutputStream; import java.io.OutputStream; public class Main { public static void writeObject(OutputStream o, Object obj) throws IOException { ObjectOutputStream oo = new ObjectOutputStream(o); try { oo.writeObject(obj); } finally { oo.close(); } } }