Hi,

thanks for the heads up, i couldn't do it with a while (readobject != null) because it skips object
but i did it using a try catch on the eofexception in a while loop

here is the solution for my code:
http://tinypaste.com/75c75d3d

thanks for the quick reply




-----Oorspronkelijk bericht----- From: JörgSchaible
Sent: Thursday, June 14, 2012 11:32 AM
To: [email protected]
Subject: [xstream-user] Re: XML reader problem

Hi Jeroen,

live mail wrote:

Hi,

I have create an xml using Xstream by using the objectOutputStreamer
(http://pastebin.com/by0JPec1 ) It has created this xml file
(http://pastebin.com/tW5Gvi8z )

As you can see there are differt objects in the xml (because the arraylist
has different types of objects in it). it saves them perfectly.

but the problem is i can’t read them back in properly

I can read them in with a objectInputStreamer but the problem is I need to
retype every object type in again.

1) I don’t know how many objects there
are in the xml file because it can get verry big (so I can’t figure out
before how many times I need to repeat the ReadObject() call

See http://xstream.codehaus.org/objectstream.html#considerations

When the end of the stream is reached, you get an java.io.EOFException.
Therefore you can loop until you get this specific exception.

2) I can’t know beforehand what type of object ReadObject will return I
need to check it with instance or something similar

You write Person instances and you get such instances back. This is like a
List<Person>. If you have instances of specialized subtypes you will have to
use in both cases the instanceof operator. So far, there's no difference
with XStream.

this is my reader code so far (http://pastebin.com/PqSUG6nf )

Looks basically fine, except the required loop.

Please help

Hope this was good enough.

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to