Here you can find the source of serializeObject(Object object)
public static byte[] serializeObject(Object object)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { public static byte[] serializeObject(Object object) { ObjectOutputStream objectOutputStream = null; ByteArrayOutputStream byteArrayOutputStream = null; try {// w ww .j av a2 s .c o m byteArrayOutputStream = new ByteArrayOutputStream(); objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); objectOutputStream.writeObject(object); return byteArrayOutputStream.toByteArray(); } catch (Exception e) { return null; } finally { try { if (null != byteArrayOutputStream) { byteArrayOutputStream.close(); } if (null != objectOutputStream) { objectOutputStream.close(); } } catch (Exception e) { } } } }