dcsimg
How to check for end of file when read object from file using readObject()?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, October 19, 2001 05:39 AM



My question is how to check for end of file when read object from file using readObject()?

For example, the data file contain few student records, then the program loop to read those student record object. How to stop the loop? Compare it with null?

Thanks first for your help. =)

Re: How to check for end of file when read object from file using readObject()?

Posted By:   John_Gallagher  
Posted On:   Sunday, November 11, 2001 08:15 PM

Assuming you do something like

fileInputStream = new FileInputStream( new File( "Filename" ) );
objectInputStream = new ObjectInputStream( fileInputStream );

to open the stream, you can do this:

while ( fileInputStream.available() > 0 )
{
myObject = ( someObject )objectInputStream.readObject();
}
About | Sitemap | Contact