Java Utililty Methods InputStream Deserialize to Object

List of utility methods to do InputStream Deserialize to Object

Description

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

Method

Objectdeserialize(InputStream in)
Deserialize from input stream
ObjectInputStream is = new ObjectInputStream(in);
return is.readObject();
Objectdeserialize(InputStream in)
deserialize
ObjectInputStream oin = new ObjectInputStream(in);
try {
    return (oin.readObject());
} catch (ClassNotFoundException e) {
    return (null);
Objectdeserialize(InputStream in, Class cls)
Deserializes the object contained in the given input stream.
if (cls == null)
    throw new NullPointerException("cls");
Object obj = deserialize(in, cls);
if (!cls.isInstance(obj)) {
    throw new InvalidObjectException("type of deserialized instance not of required class.");
return obj;
Tdeserialize(InputStream inputStream)
deserialize
if (inputStream == null)
    return null;
ObjectInputStream ois = new ObjectInputStream(inputStream);
return (T) ois.readObject();
Objectdeserialize(InputStream inputStream)
deserialize
ObjectInputStream in = null;
try {
    in = new ObjectInputStream(inputStream);
    return in.readObject();
} catch (ClassNotFoundException ex) {
    throw ex;
} catch (IOException ex) {
    throw ex;
...
Objectdeserialize(InputStream inputStream)

Deserializes an Object from the specified stream.

The stream will be closed once the object is written.

if (inputStream == null) {
    throw new IllegalArgumentException("The InputStream must not be null");
ObjectInputStream in = null;
try {
    in = new ObjectInputStream(inputStream);
    return in.readObject();
} catch (ClassNotFoundException ex) {
...
Serializabledeserialize(InputStream is)
Method description
try {
    ObjectInputStream oip = new ObjectInputStream(is);
    return (Serializable) oip.readObject();
} catch (IOException e) {
    throw new IllegalArgumentException(e);
} catch (ClassNotFoundException e) {
    throw new IllegalArgumentException(e);
Tdeserialize(InputStream is)
deserialize
ObjectInputStream in = new ObjectInputStream(is);
@SuppressWarnings("unchecked")
T e = (T) in.readObject();
in.close();
return e;
Tdeserialize(InputStream sourceInputStream, Class objectType)
deserialize
ObjectInputStream tais = null;
try {
    tais = new ObjectInputStream(sourceInputStream);
    T result = (T) tais.readObject();
    return result;
} catch (Exception e) {
    throw new IllegalStateException(e);
} finally {
...
Objectdeserialize(ObjectInputStream stream)
deserialize
if (stream == null) {
    return null;
try {
    return stream.readObject();
} catch (IOException e) {
    throw new IllegalArgumentException("Could not deserialize object", e);
} catch (ClassNotFoundException e) {
...