I want to read the contents of a xml file using XStream. I want to read the whole file, but don't know what to put in the while condition, so that XStream doesn't throw a java.io.EOFException
exception.Basically I want to stop the cycle when I reach the end of the file. The code is below:
public static void main(String[] args) throws IOException, ClassNotFoundException
{
XStream xstream = new XStream(new StaxDriver());
xstream.alias("person", Person.class);
Reader someReader = new FileReader("filename.xml");
ObjectInputStream in = xstream.createObjectInputStream(someReader);
while (???) {
Person a = (Person)in.readObject(); // Person is just a class containing a String and an int
a.print();
}
}