Advertisement
Guest User

Untitled

a guest
May 27th, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1.  
  2.     private final String weatherInfoFileName = "weatherInfo";
  3.  
  4.     private void serializeChannel()
  5.     {
  6.         try
  7.         {
  8.             FileOutputStream fos = weatherAppActivity.openFileOutput(weatherInfoFileName, Context.MODE_PRIVATE);
  9.             ObjectOutputStream os = new ObjectOutputStream(fos);
  10.             os.writeObject(channel);
  11.             os.close();
  12.             fos.close();
  13.         }
  14.         catch (IOException e)
  15.         {
  16.             e.printStackTrace();
  17.         }
  18.     }
  19.  
  20.  
  21.     private void deserializeChannel()
  22.     {
  23.         try
  24.         {
  25.             FileInputStream fis = weatherAppActivity.openFileInput(weatherInfoFileName);
  26.             ObjectInputStream is = new ObjectInputStream(fis);
  27.             channel = (Channel) is.readObject();
  28.             is.close();
  29.             fis.close();
  30.         }
  31.         catch(Exception e)
  32.         {
  33.             e.printStackTrace();
  34.         }
  35.     }
  36.  
  37.     public boolean isWeatherInfoInFile()
  38.     {
  39.         File file = new File(weatherInfoFileName);
  40.         return file.exists();
  41.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement