Java examples for XML:JAXB
marshal via JAXB
//package com.java2s; import java.io.OutputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { public static <T> void marshal(JAXBElement<T> element, Class<T> c, OutputStream os) {// w ww . jav a2 s.c om try { JAXBContext jc = JAXBContext.newInstance(c); Marshaller ma = jc.createMarshaller(); ma.marshal(element, os); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }