Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.io.IOException;
import java.io.ObjectInputStream;

public class Main {
    @SuppressWarnings("unchecked")
    public static <T> T readSerializedObject(Context context, String fileName)
            throws FileNotFoundException, IOException, ClassNotFoundException {
        FileInputStream fis = context.openFileInput(fileName);
        ObjectInputStream in = new ObjectInputStream(fis);

        T out = (T) in.readObject();

        in.close();
        fis.close();
        return out;
    }
}