These
two classes are used to store object’s state permanently in files or send to
remote computer via network.
ObjectInputStream – It is a
subclass of ObjectInput interface. It implements the following method to read
object from underline input stream – public
Object readObject() throws IOException
ObjectOutputStream – It is a
subclass of ObjectOutput interface. It implements the following method to write
object to underline OutputStream – public
void writeObject(Object ob) throws IOException
Note – To write or store object
in external world it must be of type java.io.Serializable interface. It means
this object’s class must be a subclass of java.io.Serializable interface, else
writeObject() methods throws java.io.NotSerializableException
Note – Objects like DIS and
DOS, OIS and OOS cannot be used to connect to source and destination directly.
Hence, their constructors take other input and output stream class objects.
No comments:
Post a Comment