new Marshaller for JAXB - Java XML

Java examples for XML:JAXB

Description

new Marshaller for JAXB

Demo Code


//package com.java2s;

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

public class Main {
    public static void main(String[] argv) throws Exception {
        Class classJAXB = String.class;
        System.out.println(newMarshaller(classJAXB));
    }/*from   w  ww . j  av  a 2  s. co m*/

    private static Marshaller newMarshaller(Class<?> classJAXB)
            throws Exception {
        return newContext(classJAXB).createMarshaller();
    }

    private static JAXBContext newContext(Class<?> classJAXB)
            throws Exception {
        return JAXBContext.newInstance(classJAXB);
    }
}

Related Tutorials