Java XML JAXB Marshaller marshallToXml(String zpackage, Writer writer, Object data)

Here you can find the source of marshallToXml(String zpackage, Writer writer, Object data)

Description

marshall To Xml

License

Apache License

Declaration

public static void marshallToXml(String zpackage, Writer writer, Object data) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class Main {
    public static void marshallToXml(String zpackage, Writer writer, Object data) {
        JAXBContext jc;// w  w  w. j a v  a 2  s  . c o m
        try {
            jc = JAXBContext.newInstance(zpackage);
            Marshaller m = jc.createMarshaller();
            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

            m.marshal(data, writer);

        } catch (JAXBException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. marshallJAXBObject(String namespace, Object o)
  2. marshallMessage(Object message, Marshaller marshaller, DataOutputStream dos)
  3. marshallObjectAsString(Class clazz, T object)
  4. marshallObjectToXML(final Object jaxbModel, final URL schemaURL)
  5. marshallToString(Object jaxbElement, Class c)
  6. marshallXml(final Object object)
  7. marshallXMLInConsole(Object obj)
  8. marshalObject(Object obj, File file)
  9. marshalObjectToXml(Object object, String xmlFilePath)