Sign In/My Account | View Cart  
advertisement

Article:
 Serializing Java Objects with XStream
Subject: Desirialize example correction
Date: 2007-05-25 06:57:47
From: waikar

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;


class Date {
int year = 2004;
int month = 8;
int day = 15;
}


public class Deserialize {


public static void main(String[] args) {


XStream xstream = new XStream(new DomDriver());


Date date = new Date();


xstream.alias("date", Date.class);


String xml = xstream.toXML(date);


System.out.print(xml);


Date newdate = (Date)xstream.fromXML(xml);
newdate.month = 12;
newdate.day = 2;


String newxml = xstream.toXML(newdate);


System.out.print("\n\n" + newxml);
}
}


Previous Message Previous Message   Next Message No Next Message


Sponsored By: