FileInputStream file = new FileInputStream(new File("D:\\project\\XX-1.xml"));
XStream xstream = new XStream();
XStream.setupDefaultSecurity(xstream); //xStream:Security framework of XStream not initialized, XStream is probably vulnerable
xstream.allowTypes(new Class[]{xxx.class, xxx.class, xxx.class});
xstream.setMode(XStream.ID_REFERENCES);
xstream.processAnnotations(Schedule.class);
xstream.autodetectAnnotations(true);
xstream.ignoreUnknownElements(); //XStream报异常:UnknownFieldException
xxx schedule = (xxxx) xstream.fromXML(
new File("xxx.xml"));
System.out.println(schedule);
xsteam xml to java object.
最新推荐文章于 2022-04-12 11:36:40 发布
本文详细介绍了如何使用xstream库将XML数据高效地转换为Java对象,包括配置过程、核心API解析及实际转换示例,帮助开发者更好地理解和应用XML到Java对象的映射技术。
摘要由CSDN通过智能技术生成