Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.FileOutputStream;
import java.io.IOException;

import java.io.ObjectOutput;
import java.io.ObjectOutputStream;

import android.content.Context;

public class Main {
    public static void saveObject(Context context, String fileName, Object obj) throws IOException {
        FileOutputStream fos = context.openFileOutput(fileName, Context.MODE_PRIVATE);
        ObjectOutput out = null;
        try {
            out = new ObjectOutputStream(fos);
            out.writeObject(obj);
            out.flush();
        } finally {
            out.close();
            fos.close();
        }

    }
}