Convert byte array To Object via ObjectInputStream - Android File Input Output

Android examples for File Input Output:Byte Array Convert

Description

Convert byte array To Object via ObjectInputStream

Demo Code


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

import java.io.ObjectInputStream;

public class Main {

    public static Object byteToObject(byte[] bytes) throws Exception {
        ObjectInputStream ois = null;
        try {// w  w  w  .ja  v a  2 s  .  c  o  m
            ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
            return ois.readObject();
        } finally {
            if (ois != null)
                ois.close();
        }
    }
}

Related Tutorials