To read objects from a file, we use the class _________________ .
A) InputObjectStream
B) ObjectInputStream
C) ObjectStream
D) ObjectInput
1
Expert's answer
2012-12-13T08:11:10-0500
To read objects from a file, we use the classObjectInputStream.
For example: //this method reads object, that had been written to thefile //you should to know what type of object you will read. //It necessary for casting read object to your typepublic Object read(File file) throwsException { FileInputStreamfis = new FileInputStream(file); ObjectInputStreamoin = new ObjectInputStream(fis); return (Object)oin.readObject(); }
Comments
Leave a comment