Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Log; import java.io.FileOutputStream; import java.io.ObjectOutputStream; import java.io.PrintWriter; import java.io.StringWriter; public class Main { public static void saveObj(String fileName, Object obj) { try { FileOutputStream fout = new FileOutputStream(fileName); ObjectOutputStream oout = new ObjectOutputStream(fout); oout.writeObject(obj); fout.close(); oout.close(); } catch (Exception e) { printE("OpusTool", e); } } 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()); } }