Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.io.*;

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

public class Main {

    public static byte[] serializerBytes(Object xmlObj) throws JAXBException {
        JAXBContext context = JAXBContext.newInstance(xmlObj.getClass());
        Marshaller marshaller = context.createMarshaller();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        marshaller.marshal(xmlObj, baos);
        return baos.toByteArray();
    }
}