Java XML JAXB Marshaller marshal(Class clazz, T obj)

Here you can find the source of marshal(Class clazz, T obj)

Description

marshal

License

Open Source License

Declaration

public static <T> String marshal(Class<T> clazz, T obj) throws JAXBException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.StringWriter;

import javax.xml.bind.JAXBContext;

import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

public class Main {
    public static <T> String marshal(Class<T> clazz, T obj) throws JAXBException {
        StringWriter out = new StringWriter();
        JAXBContext context = JAXBContext.newInstance(clazz);
        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.marshal(obj, out);/*from   w w  w .  j  a v  a 2  s.c om*/
        return out.toString();
    }
}

Related

  1. isSunCanonicalization(@Nonnull final Marshaller aMarshaller)
  2. isSunJAXB2Marshaller(@Nullable final Marshaller aMarshaller)
  3. marshal(Class clz, T marshalObj)
  4. marshal(Class c, String xml)
  5. marshal(Class c, String xml)
  6. marshal(Class clazz, T object)
  7. marshal(final Object obj, final Class... classes)
  8. marshal(final Object object)
  9. marshal(final Object object)