Java Object Deserialize deserialize(final byte[] data)

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

Description

deserialize

License

Open Source License

Declaration

public static final synchronized Object deserialize(final byte[] data)
            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 final synchronized Object deserialize(final byte[] data)
            throws IOException, ClassNotFoundException {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
        ObjectInputStream is = new ObjectInputStream(byteArrayInputStream);
        return is.readObject();
    }//ww  w  . ja  v a 2s .c o  m

    public static final synchronized Object deserialize(final Byte[] data)
            throws IOException, ClassNotFoundException {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(toPrimitive(data));
        ObjectInputStream is = new ObjectInputStream(byteArrayInputStream);
        return is.readObject();
    }

    public static final synchronized byte[] toPrimitive(final Byte[] bytes) {
        byte[] primitiveBytes = new byte[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            primitiveBytes[i] = bytes[i];
        }
        return primitiveBytes;
    }
}

Related

  1. deserialize(byte[] serializedData)
  2. deserialize(byte[] serializedData, int startPos, int length)
  3. deserialize(byte[] serializedObject)
  4. deserialize(byte[] sf)
  5. deserialize(final byte[] data)
  6. deserialize(final byte[] inBytes)
  7. deserialize(final byte[] serialized)
  8. deserializeFromByte(byte[] value)
  9. deserializeFromByteArray(byte[] bytes)