Java XML JAXB Marshaller marshaller(Object o, Class T)

Here you can find the source of marshaller(Object o, Class T)

Description

marshaller

License

Apache License

Declaration

public static String marshaller(Object o, Class<?> T) 

Method Source Code


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

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

import java.io.*;

public class Main {
    public static String marshaller(Object o, Class<?> T) {
        JAXBContext jc;/*from   ww w. ja va2 s.  c  o  m*/
        Marshaller marshaller;
        StringWriter writer = new StringWriter();
        try {
            jc = JAXBContext.newInstance(T);
            marshaller = jc.createMarshaller();
            marshaller.marshal(o, writer);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
        return writer.toString();

    }
}

Related

  1. marshall(Object obj, URL schemaURL, Class... classesToBeBound)
  2. marshall(Object toMarshall)
  3. marshall(OutputStream os, JAXBElement element)
  4. marshall(String cntxtPkg, Object obj, OutputStream out)
  5. marshall(String file, JAXBElement object, Class context)
  6. marshaller(Object obj, File file)
  7. marshallerObject(Class c, Object o)
  8. marshallJAXBObject(String namespace, Object o)
  9. marshallMessage(Object message, Marshaller marshaller, DataOutputStream dos)