import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;
public class XSMain
{
public static void main(String[] args)
{
MyBean b = new MyBean();
// b.setName("Jhon");
// b.setAge(12);
// XStream xs = new XStream();
// xs.alias("Bean", MyBean.class);
// String xml = xs.toXML(b);
// System.out.println(xml);
File f = new File("D:\\work\\SimpleXStream\\src\\Bean.xml");
InputStream is = null;
try
{
is = new FileInputStream(f);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
XStream xs = new XStream(new DomDriver());
xs.alias("Bean", MyBean.class);
b = (MyBean)xs.fromXML(is);
System.out.println(b.getName());
}
}