Here you can find the source of toBlob(Object obj)
public static byte[] toBlob(Object obj) throws java.io.IOException
//package com.java2s; import java.io.ObjectOutputStream; import java.io.ByteArrayOutputStream; public class Main { public static byte[] toBlob(Object obj) throws java.io.IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj);//from ww w . java 2 s .c o m oos.flush(); oos.close(); bos.close(); byte[] data = bos.toByteArray(); return data; } }