Java Object Deserialize deserializeObject(byte[] bytes)

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

Description

deserialize the compress bytes

License

Open Source License

Parameter

Parameter Description
bytes a parameter

Exception

Parameter Description
IOException an exception
ClassNotFoundException an exception

Return

Object deserialized object

Declaration

public static Object deserializeObject(byte[] bytes) throws IOException, ClassNotFoundException 

Method Source Code


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

import java.io.IOException;

import java.io.ObjectInputStream;

import java.util.zip.InflaterInputStream;

public class Main {
    /**//from  w w  w. j  a  v a 2s . c  o m
     * deserialize the compress bytes
     * @param bytes
     * @throws IOException
     * @throws ClassNotFoundException
     * @return Object deserialized object
     */
    public static Object deserializeObject(byte[] bytes) throws IOException, ClassNotFoundException {
        if ((bytes == null) || (bytes.length == 0)) {
            return null;
        }

        ByteArrayInputStream inbytes = new ByteArrayInputStream(bytes);
        InflaterInputStream inflating = new InflaterInputStream(inbytes);
        ObjectInputStream in = new ObjectInputStream(inflating);

        Object deserializedObject = in.readObject();

        in.close();
        return deserializedObject;
    }
}

Related

  1. deserializeFromBytes(byte[] bytes, Class clazz)
  2. deserializeFromBytes(byte[] serialized, Class clazz)
  3. deserializeFromBytes(byte[] serializedObject)
  4. deserializeObject(byte[] buf)
  5. deserializeObject(byte[] bytes)
  6. deserializeObject(byte[] bytes)
  7. deserializeObject(byte[] bytes)
  8. deserializeObject(byte[] bytes)
  9. deserializeObject(byte[] data)