Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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 {
    /**
     * 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);
        }
    }
}