Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
        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();

    }
}