Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;

import java.io.ObjectOutputStream;
import java.io.OutputStream;

import android.content.Context;

public class Main {
    /**
     * Get a stream that can be used for serialization
     * 
     * @param context
     *            We'll write our data to this context private dir
     * @param name
     * @return
     * @throws IOException
     */
    public static ObjectOutputStream writeObjectStream(Context context, String name) throws IOException {
        OutputStream s = context.openFileOutput(name, Context.MODE_PRIVATE);

        // I'd prefer to not overwrite the old file, but Context doesn't offer a
        // fileRename option
        return new ObjectOutputStream(s);
    }
}