• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serialization Error- EOFException  RSS feed

 
Ranch Hand
Posts: 1906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
This question might have been asked many times before but was not able to find the solution.!!
On user selection of rows from JTable, I am writing the records to a file using Serialization like this-

Program is able to write the data successfully. While reading the data, when user selects the file,I am trying to deseralize it using follwing code-

At the end, I am getting EOFException(which from the docuentation is obivious:subclass of IOException).
My question is how to avoid this exception in such cases?Is there any way?
Thanks alot.>
 
Sheriff
Posts: 21136
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do it the way most Collection classes do it: write the number of objects first. Then in the reading, you first read back that number, then read exactly that many objects.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!