To read objects from a file, we use the class _________________ .
A) InputObjectStream
B) ObjectInputStream
C) ObjectStream
D) ObjectInput
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();
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF