Here you can find the source of writeJaxbObject(OutputStream outputStream, JAXBElement> jaxbElement, Class> modelClass)
Parameter | Description |
---|---|
outputStream | a parameter |
jaxbElement | a parameter |
modelClass | a parameter |
Parameter | Description |
---|---|
JAXBException | an exception |
public static void writeJaxbObject(OutputStream outputStream, JAXBElement<?> jaxbElement, Class<?> modelClass) throws JAXBException
//package com.java2s; //License from project: Open Source License 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 { /**/*from w w w .j ava 2s . co m*/ * * @param outputStream * @param jaxbElement * @param modelClass * @throws JAXBException */ public static void writeJaxbObject(OutputStream outputStream, JAXBElement<?> jaxbElement, Class<?> modelClass) throws JAXBException { JAXBContext context = JAXBContext.newInstance(modelClass.getPackage().getName()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(jaxbElement, outputStream); } }