Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 * Copyright (C) 2010-2014  Andreas Maier
 * CONRAD is developed as an Open Source project under the GNU General Public License (GPL).
 */

import java.beans.XMLEncoder;
import java.io.File;

import java.io.FileOutputStream;

public class Main {
    public static boolean serializeObject(File file, Object o) {
        if (file.exists()) {
            System.out.println("Warning! Object Already Exists \n Replacing File.");
        }
        try {
            FileOutputStream os = new FileOutputStream(file);
            XMLEncoder encoder = new XMLEncoder(os);
            encoder.writeObject(o);
            encoder.close();
        } catch (Exception f) {
            System.out.println("Warning! Write was Unsuccessful");
            return false;
        }
        return true;
    }
}