Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileInputStream;

import java.io.IOException;

import java.io.ObjectInputStream;

public class Main {
    public static Object readObjectFromFile(String fileName) {

        ObjectInputStream ois = null;
        FileInputStream fis = null;
        try {
            fis = new FileInputStream(fileName);
            ois = new ObjectInputStream(fis);
            return ois.readObject();

        } catch (Exception e) {

        } finally {
            if (ois != null)
                try {
                    ois.close();
                    ois = null;
                } catch (IOException e) {
                }
            if (fis != null)
                try {
                    fis.close();
                    fis = null;
                } catch (IOException e) {
                }
        }

        return null;

    }
}