Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import android.util.Log; public class Main { public static byte[] serializeObject(Object o) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { ObjectOutput out = new ObjectOutputStream(bos); out.writeObject(o); out.close(); byte[] buf = bos.toByteArray(); return buf; } catch (IOException ioe) { Log.e("serializeObject", "error", ioe); return null; } } }