title: How to reference text file for use with Scanner in Android
body: <p>I'm trying to read from a text file using java.util.Scanner. I have tried using getAssets() and putting the file in the assets folder , but I get the error "getAssets() is undefined for the type Unscramble"</p>
  
  <p>Here is the code of the method which needs to read the text file</p>
  
  <pre><code>public static String go(String word) throws FileNotFoundException
      {
          String line;
          word = Alphabetize(toAList(word));
          String solution = "";
          Scanner in = new Scanner(getAssets().open("wordlist.txt")); //gives error
          while(in.hasNext()){
              line = in.nextLine();
              if(word.equals(Alphabetize(toAList(line))))
              {
                  System.out.println(line);
                  solution=solution +"\n"+line;
              }
          }
          return "solution";
      }
      public static String hello()
      {
          return "hello";
      }
  </code></pre>
  
  <p>edit: I also tried using the raw directory, but the automatically genereated R file is seeing my text file as an int. I don't know why this is.</p>