byte array To Object - Android File Input Output

Android examples for File Input Output:Object Serialization

Description

byte array To Object

Demo Code


//package com.java2s;

import java.io.ByteArrayInputStream;

import java.io.ObjectInputStream;

public class Main {
    public static java.lang.Object byteToObject(byte[] bytes) {
        java.lang.Object obj = null;
        try {/*ww w  .  j  a  va2s  .  c  om*/
            //bytearray to object
            ByteArrayInputStream bi = new ByteArrayInputStream(bytes);
            ObjectInputStream oi = new ObjectInputStream(bi);
            obj = oi.readObject();

            bi.close();
            oi.close();
        } catch (Exception e) {
            System.out.println("translation" + e.getMessage());
            e.printStackTrace();
        }
        return obj;
    }
}

Related Tutorials