title: How to read a text file from "assets" directory as a string?
body: <p>I have a file in my assets folder... how do I read it?</p>
  
  <p>Now I'm trying:</p>
  
  <pre><code>      public static String readFileAsString(String filePath)
          throws java.io.IOException{
              StringBuffer fileData = new StringBuffer(1000);
              BufferedReader reader = new BufferedReader(
                      new FileReader(filePath));
              char[] buf = new char[1024];
              int numRead=0;
              while((numRead=reader.read(buf)) != -1){
                  String readData = String.valueOf(buf, 0, numRead);
                  fileData.append(readData);
                  buf = new char[1024];
              }
              reader.close();
              return fileData.toString();
          }
  </code></pre>
  
  <p>But it cast a null pointer exception...</p>
  
  <p>the file is called "origin" and it is in folder assets </p>
  
  <p>I tried to cast it with:</p>
  
  <pre><code>readFileAsString("file:///android_asset/origin");
  </code></pre>
  
  <p>and</p>
  
  <pre><code>readFileAsString("asset/origin");``
  </code></pre>
  
  <p>but both failed... any advice?</p>