Code example for ObjectOutputStream

Methods: close, writeObject

0
public class SerializerHelper { 
	public static byte[] serializeObject(Object o) {
		ByteArrayOutputStream bos = new ByteArrayOutputStream();
 
		try { 
			ObjectOutput out = new ObjectOutputStream(bos);
			out.writeObject(o);
			out.close();
 
			// Get the bytes of the serialized object 
			byte[] buf = bos.toByteArray();
 
			return buf;
		} catch (IOException ioe) {
			Log.e("serializeObject", "error", ioe);
 
			return null; 
		} 
	} 
 
	public static Object deserializeObject(byte[] b) {