Hi guys,
I'm a newbie of XStream.
I would to deserialize this file XML to test xstream annotations:
<my last_modified="17/01/2012 16:19">
</my>
My.java class is:
@XStreamAlias("my")
public class My{
@XStreamAlias("last_modified")
@XStreamAsAttribute
private String last_modified;
public My() {
this.last_modified = "--";
}
public String getLast_modified() {
return last_modified;
}
public void setLast_modified(String last_modified) {
this.last_modified = last_modified;
}
}
I invoke with:
String path = "C:\\Desktop\\xml.xml";
InputStream inputStream = null;
Reader reader = null;
try {
inputStream = new java.io.FileInputStream(new File(path));
reader = new InputStreamReader(inputStream,
Charset.forName("UTF-8"));
}
catch(Exception e){
e.printStackTrace();
}
XStream xstream = new XStream(new StaxDriver());
xstream.processAnnotations(My.class);
My my= (My)xstream.fromXML(reader);
Can you help me?
--
*Francesco Pace**
Mail*: [email protected]
<[email protected]>*Twitter*: http://twitter.com/ceccocq
*Skype Id*: cecco.pace