Here you can find the source of serializeObject(Object object)
static public byte[] serializeObject(Object object) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; public class Main { static public byte[] serializeObject(Object object) throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); try {/*from w w w .j ava2 s.com*/ ObjectOutputStream oos = new ObjectOutputStream(os); try { oos.writeObject(object); } finally { oos.close(); } } finally { os.close(); } return os.toByteArray(); } }