Java Utililty Methods Object Deserialize

List of utility methods to do Object Deserialize

Description

The list of methods to do Object Deserialize are organized into topic(s).

Method

Objectdeserialize(byte[] objectData)
deserialize
if (objectData == null) {
    throw new IllegalArgumentException("The byte[] must not be null");
ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
ObjectInputStream in = null;
try {
    in = new ObjectInputStream(bais);
    return in.readObject();
...
Objectdeserialize(byte[] objectData)

Deserializes a single Object from an array of bytes.

if (objectData == null)
    throw new IllegalArgumentException("The byte[] must not be null");
ByteArrayInputStream bais = new ByteArrayInputStream(objectData);
return deserialize(bais);
Objectdeserialize(byte[] objectData)
deserialize
ByteArrayInputStream buffer = new ByteArrayInputStream(objectData);
try (ObjectInputStream in = new ObjectInputStream(buffer)) {
    return in.readObject();
} catch (ClassNotFoundException e) {
    throw new IllegalStateException("Unable to deserialize", e);
Objectdeserialize(byte[] serial)
Deserialized an array of bytes into a Serializable object.
ByteArrayInputStream bais = new ByteArrayInputStream(serial);
ObjectInputStream ois = new ObjectInputStream(bais);
try {
    return ois.readObject();
} finally {
    if (ois != null) {
        ois.close();
    if (bais != null) {
        bais.close();
Objectdeserialize(byte[] serial)
Redintegrate a serialized object.
ByteArrayInputStream bais = new ByteArrayInputStream(serial);
ObjectInputStream ois = null;
try {
    ois = new ObjectInputStream(bais);
    return ois.readObject();
} catch (IOException e) {
    return null;
} catch (ClassNotFoundException e) {
...
Objectdeserialize(byte[] serialized)
deserialize
try {
    ByteArrayInputStream bis = new ByteArrayInputStream(serialized);
    ObjectInputStream ois = new ObjectInputStream(bis);
    Object ret = ois.readObject();
    ois.close();
    return ret;
} catch (IOException ioe) {
    throw new RuntimeException(ioe);
...
Objectdeserialize(byte[] serializedData)
Deserializes the given serialization data and returns the object.
ByteArrayInputStream byteStream = new ByteArrayInputStream(serializedData);
ObjectInputStream ois;
Object retObject;
try {
    ois = new ObjectInputStream(byteStream);
    retObject = ois.readObject();
    ois.close();
} catch (Exception e) {
...
Objectdeserialize(byte[] serializedData, int startPos, int length)
Deserialize object from given byte array, starting at startPos and using length bytes.
try (ObjectInputStream ois = new ObjectInputStream(
        new ByteArrayInputStream(serializedData, startPos, length))) {
    return ois.readObject();
} catch (ClassNotFoundException e) {
    throw new IllegalStateException("Unmarshalling exception", e);
Objectdeserialize(byte[] serializedObject)
deserialize
try {
    ByteArrayInputStream bais = new ByteArrayInputStream(serializedObject);
    ObjectInputStream ois = new ObjectInputStream(bais);
    Object result = ois.readObject();
    ois.close();
    return result;
} catch (Exception e) {
    throw new RuntimeException("Failed to deserialize!", e);
...
Serializabledeserialize(byte[] sf)
Returns the object with the specified serialized form.
try {
    InputStream is = new ByteArrayInputStream(sf);
    ObjectInputStream ois = new ObjectInputStream(is);
    return (Serializable) ois.readObject();
} catch (Exception e) {
    throw new IllegalArgumentException(e);