Android Open Source - MathApp Storage






From Project

Back to project page MathApp.

License

The source code is released under:

MIT License

If you think the Android project MathApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ie.lc.mathApp;
/*from  w ww.  ja  va 2s .  c om*/


import java.io.*;
import java.util.ArrayList;
import java.util.List;





/**
 * Provides IO utility functions.
 */
public class Storage
{
  /**
   * Read a single object from a file.
   * @param filename
   * @param type
   * @return Reference to object
   */
  public static <T> T read( String filename, Class<T> type ) {
    T object = null;
    
    try {
      FileInputStream   fis = new FileInputStream( filename );
      ObjectInputStream ois = new ObjectInputStream( fis );
      
      object = (T) ois.readObject();
      ois.close();
    }
    catch (Exception ex) {
      throw new RuntimeException( ex );
    }
    
    return object;
  }
  
  
  
  
  
  /**
   * Write an object to a file.
   * @param filename
   * @param object
   */
  public static void write( String filename, Serializable object ) {
    try {
      FileOutputStream   fos = new FileOutputStream( filename );
      ObjectOutputStream oos = new ObjectOutputStream( fos );
      
      oos.writeObject( object );
      oos.close();
    }
    catch (Exception ex) {
      throw new RuntimeException( ex );
    }
  }
  
  
  
  
  
  /**
   * Check whether a file exists.
   * @param filename
   * @return
   */
  public static boolean exists( String filename ) {    
    return new File(filename).exists();
  }
}




Java Source Code List

ie.lc.mathApp.ActivityArithmetic.java
ie.lc.mathApp.ActivityCommonMenu.java
ie.lc.mathApp.ActivityGameBase.java
ie.lc.mathApp.ActivityScore.java
ie.lc.mathApp.ActivitySqrt.java
ie.lc.mathApp.ActivityWave.java
ie.lc.mathApp.CallbackThread.java
ie.lc.mathApp.Callback.java
ie.lc.mathApp.Geo.java
ie.lc.mathApp.Operator.java
ie.lc.mathApp.ScoreData.java
ie.lc.mathApp.Score.java
ie.lc.mathApp.SeekBarAdapter.java
ie.lc.mathApp.Storage.java
ie.lc.mathApp.TextWatcherAdapter.java
ie.lc.mathApp.Util.java
ie.lc.mathApp.Wave.java