Here you can find the source of marshal(Object obj, OutputStream stream)
public static void marshal(Object obj, OutputStream stream)
//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"); } }