Here you can find the source of serialize(Object object)
public static byte[] serialize(Object object)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; public class Main { public static byte[] serialize(Object object) { ObjectOutputStream oos = null; ByteArrayOutputStream baos = null; try {/* ww w .j av a 2 s.c o m*/ baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(object); byte[] bytes = baos.toByteArray(); return bytes; } catch (Exception e) { } return null; } }