Javatpoint Logo
Javatpoint Logo

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 javaTpoint
String in MainClass  :  JavaTpoint

Example 2

Output:

java.io.ObjectInputStream@1b28cdfa
string  in Work class  : javaTpoint





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA