Reputation: 31
The following code doesn't work. I got exception when I run these line[Object objPoints = serializer.read(Point.class, file);] In details, the source attachment doesn't contain the source for the Persister.class.
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import java.io.File;
Serializer serializer = new Persister();
File file = new File("1.xml");
Object objPoints = serializer.read(Point.class, file);
Point Class is as follow :
@Root
public class Point {
@Element
private float X;
@Element
private float Y;
}
I references from this link.
Upvotes: 1
Views: 806
Reputation: 25350
If i use the xml from your comment and your code it works:
XML:
<Point>
<X>2</X>
<Y>3</Y>
</Point>
But in the title of this question you talk about "object list" - can you be more detailed here?
If you need do deserialize a list of Points you cant use the Point
class but a list.
Btw. does your xml file contain any additional content or only this one point?
Upvotes: 1