XStream实现实体类跟XML文件互相转换

    public static Object xmlToObjectModel(String xmlData){
		XStream xstream = new XStream();
		xstream.registerConverter(new XstreamDateConverter());
		
		xstream.registerConverter(new ShortConverter());		
		xstream.registerConverter(new BigDecimalConverter());
		xstream.registerConverter(new BigIntegerConverter());
		xstream.registerConverter(new DoubleConverter());
		xstream.registerConverter(new FloatConverter());
		xstream.registerConverter(new IntConverter());
		xstream.registerConverter(new LongConverter());
		
		Object object = (Object)xstream.fromXML(xmlData);
		return object;
    }

  前面搜藏了一篇也是关于XSteam的不错。

http://wudiju.iteye.com/blog/653516

你可能感兴趣的:(xstream)