Here you can find the source of serialize(final Object object)
public static final synchronized Byte[] serialize(final Object object) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class Main { public static final synchronized Byte[] serialize(final Object object) throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(object); return toComposite(byteArrayOutputStream.toByteArray()); }//from ww w. j a v a2 s . co m public static final synchronized Byte[] toComposite(final byte[] bytes) { Byte[] compositeBytes = new Byte[bytes.length]; for (int i = 0; i < bytes.length; i++) { compositeBytes[i] = bytes[i]; } return compositeBytes; } }