Java XML JAXB Marshaller marshal(Object obj, OutputStream stream)

Here you can find the source of marshal(Object obj, OutputStream stream)

Description

marshal

License

Open Source License

Declaration

public static void marshal(Object obj, OutputStream stream) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Boeing./*  w  w  w.  j  a va  2s.  co  m*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/

import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import javax.xml.bind.JAXB;

public class Main {
    public static void marshal(Object obj, OutputStream stream) {
        JAXB.marshal(obj, stream);
    }

    public static String marshal(Object obj) throws UnsupportedEncodingException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        marshal(obj, os);
        return new String(os.toByteArray(), "UTF-8");
    }
}

Related

  1. marshal(Object obj)
  2. marshal(Object obj)
  3. marshal(Object obj, Class clazz)
  4. marshal(Object obj, OutputStream out)
  5. marshal(Object obj, OutputStream out, Class... boundClasses)
  6. marshal(Object object)
  7. marshal(Object object)
  8. marshal(Object object)
  9. marshal(Object object, File file, JAXBContext ctx)