Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.util.Log;

import java.io.FileInputStream;

import java.io.ObjectInputStream;

import java.io.PrintWriter;

import java.io.StringWriter;

public class Main {
    public static Object readObj(String fileName) {
        Object obj = new Object();
        try {
            FileInputStream fin = new FileInputStream(fileName);
            ObjectInputStream oin = new ObjectInputStream(fin);
            obj = oin.readObject();
            fin.close();
            oin.close();
        } catch (Exception e) {
            printE("OpusTool", e);
        } finally {
            return obj;
        }
    }

    public static void printE(String tag, Exception e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        Log.e(tag, sw.toString());
    }
}