Android Byte Array to Object Convert ByteToObject(byte[] bytes)

Here you can find the source of ByteToObject(byte[] bytes)

Description

Byte To Object

Declaration

public static Object ByteToObject(byte[] bytes) 

Method Source Code

//package com.java2s;
import java.io.ByteArrayInputStream;

import java.io.ObjectInputStream;

public class Main {
    public static Object ByteToObject(byte[] bytes) {
        Object obj = null;/*from w ww .ja  v  a 2 s .  c  o m*/
        try {
            // bytearray to object
            ByteArrayInputStream bi = new ByteArrayInputStream(bytes);
            ObjectInputStream oi = new ObjectInputStream(bi);

            obj = oi.readObject();
            bi.close();
            oi.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return obj;
    }
}

Related

  1. byteToObject(byte[] bytes)
  2. getObject(byte[] bytes)