Here you can find the source of write(Object jaxbAnnotatedObj, OutputStream os)
public static void write(Object jaxbAnnotatedObj, OutputStream os) throws JAXBException
//package com.java2s; //License from project: Open Source License import java.io.OutputStream; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; public class Main { public static void write(Object jaxbAnnotatedObj, OutputStream os) throws JAXBException { JAXBContext context = JAXBContext.newInstance(jaxbAnnotatedObj.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(jaxbAnnotatedObj, os); }/*www.j a va2s.c o m*/ public static void write(Object jaxbAnnotatedObj, OutputStream os, boolean outputAsFragment) throws JAXBException { JAXBContext context = JAXBContext.newInstance(jaxbAnnotatedObj.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FRAGMENT, outputAsFragment); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(jaxbAnnotatedObj, os); } }