147
Java ObjectInputStream readField() Method
The readField() method of ObjectInputStream class is used to read the persistent fields from the stream and makes them available by name.
Syntax
Parameter
No parameter is passed.
Returns
the GetField object representing the persistent fields of the object being deserialized
Throws
ClassNotFoundException – if the class of a serialized object could not be found.
IOException – if an I/O error occurs.
NotActiveException – if the stream is not currently reading objects.
Example 1
Output:
Welcome to TutorAspire
Example 2
Output:
Using readFields() : Welcome to TutorAspire ---------------------------------------------------------- TutorAspire
Next TopicJava ObjectInputStream