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

Tdeserialize(final byte[] data)
Deserialize an object from the specified byte array and returns the result.
try {
    final ByteArrayInputStream bas = new ByteArrayInputStream(data);
    final ObjectInputStream ois = new ObjectInputStream(bas);
    return (T) ois.readObject();
} catch (final Exception ex) {
    throw new IllegalStateException("Could not deserialize", ex);
Objectdeserialize(final byte[] data)
deserialize
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(data);
ObjectInputStream is = new ObjectInputStream(byteArrayInputStream);
return is.readObject();
Tdeserialize(final byte[] inBytes)
Deserialize an object.
final ByteArrayInputStream inputStream = new ByteArrayInputStream(inBytes);
return deserialize(inputStream);
Objectdeserialize(final byte[] serialized)
This method will accept a serialized version of any object defined in the system.
final ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serialized));
return ois.readObject();
VdeserializeFromByte(byte[] value)
deserialize From Byte
if (null == value || value.length <= 0) {
    return null;
V reValue = null;
ByteArrayInputStream bm = null;
ObjectInputStream om = null;
try {
    bm = new ByteArrayInputStream(value);
...
SerializabledeserializeFromByteArray(byte[] bytes)
deserialize From Byte Array
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes));
try {
    return deserializeFromStream(in);
} finally {
    in.close();
ObjectdeserializeFromByteArray(byte[] encodedValue, String description)
Deserializes an object from the given array of bytes, e.g., as serialized using #serializeToByteArray , and returns it.
try {
    try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(encodedValue))) {
        return ois.readObject();
} catch (IOException | ClassNotFoundException exn) {
    throw new IllegalArgumentException("unable to deserialize " + description, exn);
ObjectdeserializeFromByteArray(byte[] in)
Utility method to deserialize Object from byte[].
Object object;
try {
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(in));
    try {
        object = ois.readObject();
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    ois.close();
} catch (IOException e) {
    throw new RuntimeException(e);
return object;
TdeserializeFromBytes(byte[] bytes, Class clazz)
deserialize From Bytes
ByteArrayInputStream byteStream = new ByteArrayInputStream(bytes);
ObjectInputStream objectStream = new ObjectInputStream(byteStream);
Object output = objectStream.readObject();
return clazz.cast(output);
TdeserializeFromBytes(byte[] serialized, Class clazz)
Deserialize a String obtained via #serializeIntoBytes(Serializable) into an object.
try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serialized))) {
    return clazz.cast(ois.readObject());
} catch (ClassNotFoundException e) {
    throw new IOException(e);