title: How to referencing my raw txt file with FileReader?
body: <p>I'm trying to teach myself how to read a raw resources text file into a multidimensional array without much luck thus far.  Here is the raw text file:</p>
  
  <pre><code>ken todd
  stuart brian
  bob stewart
  orange apple
  
  green red
  </code></pre>
  
  <p>The code I have is shown below.</p>
  
  <pre><code>   public void LoadFromFile (){
  
          //  int fileId = (getResources().getIdentifier("text_file",
           //        "raw", getPackageName()));
          Scanner scan = new Scanner(new FileReader(R.raw.text_file);
          // initialises the scanner to read the text_file
  
          String[][] entries = new String[6][2];
          // creates a 2d array with 6 rows and 2 columns.
  
          int i = 0;
          while (scan.hasNextLine()) {
              entries[i] = scan.nextLine().split("\\s+");
              i++;
          }
          //loops through the file and splits on a space
  
          for (int row = 0; row &lt; entries.length; row++) {
              for (int col = 0; col &lt; entries[0].length; col++) {
                  if (entries[row][col] != null) {
                      System.out.print(entries[row][col] + " ");
                  }
              }
              if (entries[row][0] != null) {
                  System.out.print("\n");
              }
          }
          //prints the contents of the array that are not "null"
      }
  </code></pre>
  
  <p>I'm getting an error on the scanner line. Specifically FileReader(R.raw.text_file) I get </p>
  
  <blockquote>
    <p>Cannot resolve constructor 'FileReader(int)'</p>
  </blockquote>
  
  <p>Obviously FileReader is looking for an int and i tried to do that by putting the file ID int an int variable and then using the int variable in the FileReader but that didn't work either.</p>
  
  <pre><code>int fileId = (getResources().getIdentifier("text_file", 
          "raw", getPackageName()));
  Scanner scan = new Scanner(new FileReader(fileId);
  </code></pre>
  
  <p>It gave me the same error</p>
  
  <blockquote>
    <p>Cannot resolve constructor 'FileReader(int)'</p>
  </blockquote>
  
  <p>What am I doing wrong here?  Anybody got tips in how to get a file put into an array?</p>
  
  <p>Cheers</p>
  
  <p>Airfix</p>