JAXB XML转Bean,Bean转XML

前端之家收集整理的这篇文章主要介绍了JAXB XML转Bean,Bean转XML前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
xml转Bean JAXBContext context = JAXBContext.newInstance(Bean.class); Unmarshaller unmarshaller = context.createUnmarshaller(); Bean bean = (Bean) unmarshaller.unmarshal(new StringReader(xml)); Bean转Xml JAXBContext context = JAXBContext.newInstance(Bean.class); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,true); StringWriter writer = new StringWriter(); marshaller.marshal(bean,writer);
原文链接:https://www.f2er.com/xml/294368.html

猜你在找的XML相关文章