Android Open Source - generalsbuzz Read Local Data Task






From Project

Back to project page generalsbuzz.

License

The source code is released under:

MIT License

If you think the Android project generalsbuzz 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 me.kworden.wlcalendar2.async;
/*  w  ww.  j a v  a  2  s  . co m*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

import me.kworden.wlcalendar2.struct.MonthYearParcel;

import android.content.Context;
import android.os.AsyncTask;

public class ReadLocalDataTask extends AsyncTask<MonthYearParcel, Void, ArrayList<String>>
{
  private Context m_context;
  
  public ReadLocalDataTask(Context p_context)
  {
    m_context = p_context;
  }
  
  @Override
  protected ArrayList<String> doInBackground(MonthYearParcel ... p_args)
  {
    ArrayList<String> t_data = new ArrayList<String>();
    
    System.out.println("Reading local data...");
    
    for(MonthYearParcel i_time : p_args)
    {
      try
      {
        t_data.add(loadFile(i_time.getAsFileName()));
      }
      catch(Exception err)
      {
        err.printStackTrace();
      }
    }
    
    return t_data;
  }
  
  @Override
  public void onPostExecute(ArrayList<String> p_data)
  {
    new ParseDataTask(m_context).execute(p_data.toArray(new String[p_data.size()]));
  }
  
  private String loadFile(String p_file_name) throws IOException
  {
    String i_read;
      StringBuffer t_buffer = new StringBuffer();
    FileInputStream t_fis = m_context.openFileInput(p_file_name);
    BufferedReader t_reader = new BufferedReader(new InputStreamReader(t_fis));
    
      if(t_fis != null)
      {                            
          while((i_read = t_reader.readLine()) != null)
          {    
              t_buffer.append(i_read + "\n" );
          }               
      }       
    t_fis.close();
    
    return t_buffer.toString();
  }
}




Java Source Code List

me.kworden.wlcalendar2.BuildConfig.java
me.kworden.wlcalendar2.BuildConfig.java
me.kworden.wlcalendar2.MainActivity.java
me.kworden.wlcalendar2.SettingsActivity.java
me.kworden.wlcalendar2.adapter.EventAdapter.java
me.kworden.wlcalendar2.async.CheckLocalDataTask.java
me.kworden.wlcalendar2.async.ParseDataTask.java
me.kworden.wlcalendar2.async.ReadLocalDataTask.java
me.kworden.wlcalendar2.async.RequestRemoteDataTask.java
me.kworden.wlcalendar2.async.StoreDataTask.java
me.kworden.wlcalendar2.fragment.EventDisplayFragment.java
me.kworden.wlcalendar2.fragment.EventInfoFragment.java
me.kworden.wlcalendar2.fragment.SettingsFragment.java
me.kworden.wlcalendar2.receiver.CheckLocalDataReceiver.java
me.kworden.wlcalendar2.receiver.RequestRemoteDataReceiver.java
me.kworden.wlcalendar2.receiver.UpdateRowsReceiver.java
me.kworden.wlcalendar2.struct.MonthYearParcel.java
me.kworden.wlcalendar2.struct.WLEventClassifier.java
me.kworden.wlcalendar2.struct.WLEventLinebreak.java
me.kworden.wlcalendar2.struct.WLEvent.java
me.kworden.wlcalendar2.struct.WLHeader.java
me.kworden.wlcalendar2.util.APP.java
me.kworden.wlcalendar2.util.BROADCAST.java
me.kworden.wlcalendar2.util.MD5.java
me.kworden.wlcalendar2.util.PATTERNS.java
me.kworden.wlcalendar2.util.STATUS.java