Hey guys,
I'm on my way to certify (i gave myself two weeks but I think i have to reconsider
but am reading as fast as I can..
I am currently reading about ObjectInputStream/OutputStreams. I have saved a file with 10 products (products, see below for class) and I am able to retrieve them without a hitch. No worries there.
However, what I wanted to do, is to retrieve a unknown number of Products from a file. For example I write 10 Products, then
append another 10 products to the file, making it 20 products in the file.
When I try to deserialize the objects, it will read the first 10 without a problem, but will encounter a unknown value when it reaches 10.
Anyone know why?
Here is a sample of the code, for the readObjects method.
Product is just a simple class, implementing the Serializable interface. No mumbo jumpbo here.
edit: Added
static main() and
public void writeObjects().