Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.io.ObjectInputStream;

public class Main {
    public static Object readAsObject(File source) throws IOException, ClassNotFoundException {
        FileInputStream in = new FileInputStream(source);
        try {
            ObjectInputStream oi = new ObjectInputStream(in);
            return oi.readObject();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}