Home » Java ObjectInputStream readObject() Method with Examples

Java ObjectInputStream readObject() Method with Examples

by Online Tutorials Library

Java ObjectInputStream readObject() Method

The readObject() method of ObjectInputStream class is used to read an object from the objectinputstream. It reads the class of the object, the signature of the class, static, non-static fields and supertype.

Syntax

Parameter

NA

Returns

The object read from the stream.

Throws

ClassNotFoundException

InvalidClassException

StreamCorruptedException

OptionalDataException

IOException

Example 1

Output:

String in Serializable Class   : Welcome to TutorAspire String in MainClass  : TutorAspire 

Example 2

Output:

[email protected]  string  in Work class  : TutorAspire 

You may also like