Android examples for File Input Output:Byte Array Convert
Convert object to byte array
//package com.java2s; import java.io.ByteArrayOutputStream; import java.io.ObjectOutputStream; public class Main { public static byte[] objectToByte(Object obj) throws Exception { ObjectOutputStream oos = null; try {//from w w w . java2s .c om ByteArrayOutputStream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); oos.writeObject(obj); return bos.toByteArray(); } finally { if (oos != null) oos.close(); } } }