浏览 2045 次
锁定老帖子 主题:xstream
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2011-09-07
xstream:
XStream xstream = new XStream(); // XStream xstream = new XStream(new DOMDriver());//线程安全 xstream.alias("person", Person.class); xstream.alias("phonenumber", PhoneNumber.class); Person person = new Person("Chen", "Tao"); person.setPhone(new PhoneNumber(123, "1234-456")); person.setFax(new PhoneNumber(123, "9999-999")); //序列化 String xml = xstream.toXML(person); System.out.println(xml); //反序列化 XStream xstream2 = new XStream(); xstream2.alias("person", Person.class); xstream2.alias("phonenumber", PhoneNumber.class); xstream2.fromXML(xml); // Person newPerson = (Person) xstream2.fromXML(xml);
用到的包: xstream-1.4.1.jar xpp3_min-1.1.4c.jar --用于反序列化 xmlpull-1.1.3.1.jar
ps:真他妈的慢啊 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |