• Post Reply Bookmark Topic Watch Topic
  • New Topic

ObjectInputStream.available() returning 0, but readObject returns the object  RSS feed

 
Kumar Raja
Ranch Hand
Posts: 548
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I'm not sure, what stupidity I'm doing here. But I'm trying to serialize a collection of Person objects, collected in a HashSet. I know that serialization part is working fine. but coming to deserialization, I have been trying some thing like below



When I invoke ois.readObject() , it is returning me the object, but when I invoke available() it is returning 0 and Exception when readInt() is called.

I wanted to call


Is the above code not the correct way of iterating over serialized objects.

What is the mistake I'm doing here ?
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Available doesn't do what you think it does.
 
Kumar Raja
Ranch Hand
Posts: 548
2
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Rob.
 
Rob Spoor
Sheriff
Posts: 20903
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!