• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading whith while loop from serilizable file

 
Scott Pike
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm doing a class project about input output with serilizable projects and I'm not sure what I should use to get stuff out of the serilized file. Last time we used csv and used while(it.hasMoreTokens), but this time its a serialized file and I don't know what condition to use. The file has multiple objects. I wrote an arraylist out to the file and the array list held objects of JavaBean type. How do I read it from the file back into an arraylist ?
What condition for the while loop?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We had a question like this not long ago. My contribution to the conversation was to read until the object input stream throws an exception, which is not a very pretty thing. You can read bytes off the stream as well as objects, so a nicer idea was to put a count at the beginning of the stream. You could read the count from a normal stream, then read the rest using object stream. You could also put some kind of marker at the end, maybe just serialize a String that says "End of stream"? Any of those sound useful?
 
Joe Ess
Bartender
Posts: 9361
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the recent conversation Stan refers to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!