title: File not found for file in src\resources accessed with ClassLoader.getSystemResource("file.txt")
body: <p>I am trying to access a text file within my Java Netbeans project, but I keep getting file not found.</p>
  
  <p>Please note that I've tried specifying the file with "src\ ....", "resources\ ...", and only using the file name.</p>
  
  <p>This is my code:</p>
  
  <pre><code>static class Task extends TimerTask {
      // Load the directory as a resource
      URL dir_url = ClassLoader.getSystemResource("word_list_moby_credits.txt");
      // Turn the resource into a File
      File f = new File(dir_url.getFile());
  
      Scanner scanner = new Scanner(f);
  </code></pre>
  
  <p>I'm getting </p>
  
  <blockquote>
    <p>File not found</p>
  </blockquote>
  
  <p>on the last line of the code above.</p>
  
  <p>This is my project:</p>
  
  <p><a href="https://i.stack.imgur.com/C7fyx.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C7fyx.jpg" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/UAIJ5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UAIJ5.jpg" alt="enter image description here"></a></p>