Hello,
I am having problems using an ObjectInputStream to read from a file. My program uses a File to check whether or not a specific file exists. If it exists my program will attempt to create a FileInputStream for the file and associate an ObjectInputStream with it. It should first read an int, then start reading objects. For some reason it returns an I/O error whenever I attempt to run it.
The file itself is created by using a FileOutputStream and associating an ObjectOutputStream with it. I then write an int and my objects follow that. Any ideas what my problem could be?
File checkFile = new File("test.tst");
if(checkFile.exists())
{
ObjectInputStream readFile = new ObjetInputStream(new FileInputStream("test.tst");
int bushels = readFile.readInt();
BlueBerry firstObject = (BlueBerry) readFile.readObject();
BlueBerry secondObject = (BlueBerry) readFile.readObject();
//....
}
The test.tst file is written in such a way that it matches this reading format. If anyone can see an error in how this works I would appreciate it or any sample code I could reference! Thanks!