XStream的使用方法
来源:互联网 发布:电动机绕组数据技术 编辑:程序博客网 时间:2024/05/14 21:02
import com.thoughtworks.xstream.XStream;class Date { int year = 2004; int month = 8; int day = 15;}public class Deserialize { public static void main(String[] args) { XStream xstream = new XStream(); 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); }}
这里的输出结果如下
<date> <year>2004<year> <month>8<month> <day>15<day><date><date> <year>2004<year> <month>12<month> <day>2<day><date>
细心的人可能注意到了,输出的结果与类定义的属性是一致的,如果你属性是小写的在java类中,想要把大写的属性在XML中的值映射到java类中,那就要用到xstream.aliasField的方法了。
- XStream的使用方法
- .xstream的alias使用方法
- XStream使用方法
- XStream使用方法
- XStream使用方法
- xstream+xpp超强黄金组合使用方法
- xstream+xpp超强黄金组合使用方法
- xstream+xpp超强黄金组合使用方法
- Xstream的使用
- XStream的分析
- xstream插件的使用
- 关于XStream的使用
- xstream的别名使用
- xstream 别名的用法
- Xstream的使用
- xstream 别名的用法
- Xstream的简单使用
- ajax04 xstream的讲解
- mysql 授权root帐号可以远程访问,导入sql文件,登录mysql用root帐号,设置密码
- 为什么使用NoSQL
- Android 为程序添加桌面快捷方式
- asp.net中Excel导入sql server数据库
- 30分钟,让你成为一个更好的程序员
- XStream的使用方法
- POC [Proof of Concept] 原型 / 概念证明
- Lucene 3.0 原理与代码分析
- vim高级技巧——使用vim对比两个文件
- Centos 开起自动启动设置
- 如何计算时间复杂度
- 吴文虎_程序设计基础_清华大学视频教程
- Oracle 11g存在密码过期问题
- 自动检测TXT文件编码