Android examples for java.lang:array convert
Convert byte array to Serializable object.
import java.io.ByteArrayInputStream; import java.io.ObjectInputStream; import android.util.Log; public class Main { private static final String TAG = "ArrayUtil"; /**//from w ww .j av a 2 s . com * Convert byte array to Serializable object. * * @param data * @return */ public static Object byteArrayToObject(byte[] data) { Object result = null; try { ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data); ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); result = objectInputStream.readObject(); byteArrayInputStream.close(); objectInputStream.close(); } catch (Exception e) { Log.e(TAG, "byteArrayToObject() error: " + e); } return result; } }