Java Byte Array to Object deserialize(byte[] b)

Here you can find the source of deserialize(byte[] b)

Description

deserialize

License

Open Source License

Declaration

public static Object deserialize(byte[] b) throws IOException, ClassNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayInputStream;

import java.io.IOException;
import java.io.ObjectInputStream;

public class Main {
    public static Object deserialize(byte[] b) throws IOException, ClassNotFoundException {
        Object obj = null;/*from   w  ww.  jav  a2s .  co  m*/
        ObjectInputStream oin = null;
        try {
            //System.out.println("read obj: " + b.length);
            ByteArrayInputStream bin = new ByteArrayInputStream(b);
            oin = new ObjectInputStream(bin);
            obj = oin.readObject();
            return obj;
        } finally {
            if (oin != null)
                oin.close();
        }
    }
}

Related

  1. deserialize(byte[] array)
  2. deserialize(byte[] blob)
  3. deserialize(byte[] buf)
  4. deserialize(byte[] buf)
  5. deserialize(byte[] buffer, int count)