Read a simple text file
<p>Hi everyone I am trying to read the date from a file in android. I am using Eclipse and the program is compiling and running, just it is not printing the context of the txt file. Here is my load method</p>

<pre><code>    private String load(String filename) {
        try {
//          Log.v("Home", " in the load method");
            Log.d("Home", " in the load method");

            final FileInputStream fis = openFileInput(filename);
//          final InputStream fis =  getResources().openRawResource(R.raw.pages);

            final BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line);
            }
            reader.close();
            fis.close();
            return sb.toString();
        } catch (Exception ex) {
            return "No entry exists for this file";
        }
    }
</code></pre>

<p>and in the oncreate i just access it</p>

<pre><code>String fileName = "pages.txt";
load(fileName);
</code></pre>

<p>pages.txt is in the res/raw directory. I tried to read the file with both  </p>

<pre><code>final FileInputStream fis = openFileInput(filename);
// final InputStream fis =  getResources().openRawResource(R.raw.pages);
</code></pre>

<p>but It is not printing the context.</p>

<p>I added in the onCreate method </p>

<pre><code>Log.d("File", load(fileName));
</code></pre>

<p>but is returning the catch statement <code>No entry exists for this file.</code></p>

<p>Thanks</p>
