title: Trying to read a text file in res/raw with scanner
body: <p>Hello,</p>
  
  <p>I am trying to read a file with a <a href="http://developer.android.com/reference/java/util/Scanner.html" rel="nofollow"><code>Scanner</code></a> so I can use the input of the strings to construct other objects. However my scanner is always throwing a <code>NullPointerException</code> when trying to create it. I have a <code>pig.txt</code> text file in the <code>res/raw</code> folder but my scanner can not seem to access it. I do not know what I am doing wrong. I have comment out other code of the method but still get an exception.</p>
  
  <pre><code>public void loadAchievements() {
      try {
          Scanner s = new Scanner(getResources().openRawResource(R.raw.pig));
  
          /**
           * s = s.useDelimiter("."); Scanner StringScanner; StringScanner =
           * new Scanner(s.next()); StringScanner =
           * StringScanner.useDelimiter(":"); String keep =
           * StringScanner.next(); String StringKeeper = StringScanner.next();
           * this.achievementBoard.add(new Achievement_Item(keep,
           * StringKeeper)); StringScanner.close(); s.close();
           **/
      } catch (NullPointerException e) {
          e.printStackTrace();
          System.out.println("NULLPOINTER");
      }
  }
  </code></pre>