Android examples for File Input Output:Byte Array Convert
Convert ArrayList to bytes
//package com.book2s; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; import android.util.Log; public class Main { public static final String LOGERR = "ERR"; /**// ww w .j a v a2s .c om * Convert ArrayList<String> to bytes * @param newCustomField * @param customField * @return */ public static byte[] object2Byte(Object obj) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); ObjectOutputStream dout = null; try { dout = new ObjectOutputStream(bout); dout.writeObject(obj); dout.close(); } catch (IOException e) { Log.e(LOGERR, "Unable to object to bytes", e); } return bout.toByteArray(); } }