title: Java: How to use Scanner class to read text file in resources folder
body: <p><a href="https://i.stack.imgur.com/cWXDq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cWXDq.png" alt="enter image description here"></a></p>
  
  <pre><code>import java.util.*;
  import java.io.File;
  import java.io.IOException;
  
  public class Test {
  
      public static void main(String[] args) {
          File source;
          Scanner input;
          String name;
          String id;
          Pokemon x;
          ArrayList&lt;Pokemon&gt; pokelist = null;
  
          try {
              source = new File("/resources/gen1pokemon.txt");
              input = new Scanner(source);
              input.useDelimiter(",");
              while(input.hasNext()) {
                  id = input.next();
                  name = input.next();
                  x = new Pokemon(id,name);
                  pokelist.add(x);
  
                  input.nextLine();
              }
          } catch(Exception e) {
              System.out.println(e);
          }
          System.out.println(pokelist.get(0).getName());
      }
  }
  </code></pre>
  
  <p>I have a text file in my resources folder and I am trying to read that using the Scanner class, however I get an error.
  java.io.FileNotFoundException: \resources\gen1pokemon.txt (The system cannot find the path specified)Exception in thread "main" </p>
  
  <p>Any ideas what could be causing this? I looked around and tried putting "class.getResource("file name")" reference, but I got an error doing that too when declaring file.</p>