Java XML JAXB Object to XML toXML(Object o, OutputStream os)

Here you can find the source of toXML(Object o, OutputStream os)

Description

to XML

License

Open Source License

Declaration

public static void toXML(Object o, OutputStream os) throws JAXBException 

Method Source Code

//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 toXML(Object o, OutputStream os) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(o.getClass());
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        marshaller.marshal(o, os);//from   w w w. ja v a  2s.c  o  m
    }
}

Related

  1. toString(Object o, Class clazz)
  2. toXml(Class className, Object object)
  3. toXML(final Object obj, final boolean prettyPrint)
  4. toXml(final T dto)
  5. toXML(Object o)
  6. toXml(Object o, OutputStream output)
  7. toXml(Object obj)
  8. toXml(Object object)
  9. toXML(Object thing)