示例#1
0
 /** save the demonstration to disk. */
 public void serializeDemonstration() {
   try {
     File demonstrationFile = new File(mExternalDir, DEMONSTRATION_FILE);
     Log.i(
         LOG_STRING,
         "Writing " + mDemonstration.toString() + " to " + demonstrationFile.toString());
     ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(demonstrationFile));
     // mDemonstration.writeObject(out);
     // out.writeObject(mDemonstration);
     out.close();
   } catch (Exception e) {
     Log.e(LOG_STRING, "Error opening demonstration output: " + e.toString());
   }
 }
示例#2
0
 public void unserializeDemonstration() {
   try {
     File file = new File(mExternalDir, DEMONSTRATION_FILE);
     Log.i(LOG_STRING, "Reading from: " + file.toString());
     if (!file.exists()) {
       Log.i(LOG_STRING, "DOES NOT EXIST");
     }
     ObjectInputStream in = new ObjectInputStream(new FileInputStream(file));
     // mDemonstration = (Demonstration) in.readObject();
     mDemonstration = new Demonstration();
     // mDemonstration.readObject(in);
     in.close();
   } catch (Exception e) {
     System.err.println("Way to f**k it up: " + e.getMessage());
   }
   Log.i(LOG_STRING, "Read demonstration: " + mDemonstration.toString());
 }