Java XML JAXB Marshaller marshal(Marshaller m, File out, Object o)

Here you can find the source of marshal(Marshaller m, File out, Object o)

Description

Stores object into file.

License

LGPL

Parameter

Parameter Description
m marshaller
out output file
o object to be stored

Exception

Parameter Description
IOException if some error occurs

Declaration

private static void marshal(Marshaller m, File out, Object o) throws IOException 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.io.File;

import java.io.FileOutputStream;
import java.io.IOException;

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

public class Main {
    /**/*from   ww w.j a  v a2 s. c  o  m*/
     * Stores object into file.
     *
     * @param m marshaller
     * @param out output file
     * @param o object to be stored
     * @throws IOException if some error occurs
     */
    private static void marshal(Marshaller m, File out, Object o) throws IOException {
        try (FileOutputStream fos = new FileOutputStream(out)) {
            m.marshal(o, fos);
        } catch (JAXBException ex) {
            throw new IOException("Cannot write object to file - " + ex.getMessage(), ex);
        }
    }
}

Related

  1. marshal(final Object object)
  2. marshal(JAXBContext context, Object object, Writer writer, Map properties)
  3. marshal(JAXBElement e, File f)
  4. marshal(JAXBElement jaxbElement, Class cls)
  5. marshal(JAXBElement value, String contextPath, OutputStream out, ClassLoader classLoader)
  6. marshal(Marshaller marshaller, Object object, String filename)
  7. marshal(Marshaller marshaller, Object object, String filename)
  8. marshal(Object bean)
  9. marshal(Object entity)