Here you can find the source of encode(Object o)
public static byte[] encode(Object o) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.*; public class Main { public static byte[] encode(Object o) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream os = new ObjectOutputStream(bos); os.writeObject(o);//from w w w . j a v a2s .c om os.close(); bos.close(); byte[] arr = bos.toByteArray(); return arr; } }