deserialize byte array to Object - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

deserialize byte array to Object

Demo Code


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

import java.io.ObjectInputStream;

import android.util.Log;

public class Main {
    public static Object deserialize(byte[] data) {
        try {//from   w  ww  .j  a  v a2  s.  c  om
            ByteArrayInputStream in = new ByteArrayInputStream(data);
            ObjectInputStream is = new ObjectInputStream(in);
            return is.readObject();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related Tutorials