title: File not found with Java's getResource
body: <p>I am trying to load a file called <code>Test</code> from my class, but somehow Java says, that the file does not exist, while it clearly does and neither the URL object <code>url</code> is null nor does it contain an invalid path and when I debug the program, the File object <code>file</code> has the right path stored in it. When I print out <code>file.getPath()</code> and paste it into the Windows Explorer it opens up just fine. I am running Eclipse, but I tried running the program in a console and it doesn't work either.</p>
  
  <pre><code>public static void main(String[] args) {
      URL url = Test.class.getResource("/Test");
      File file = new File(url.toExternalForm());
  
      if (!file .exists()) {
        System.out.println("File does not exist: " + file.getPath());
        System.exit(-1);
      }
  }
  </code></pre>
  
  <p>I tried it with <code>getResource("Test")</code>, <code>File("Test")</code> and <code>File("/Test")</code> as well, but that didn't work either. I don't know why this happens know, since I work often with files and never had a problem. </p>
  
  <p>The file I want to load is located in a source folder and yes, I checked, it is recognized as a source folder in Eclipse and is in the classpath. By the way the file <em>is</em> actually just called <code>Test</code> without an extension.</p>
  
  <p>Bin folder:</p>
  
  <pre><code>bin/
    |___package/Test.class
    |___Test
  </code></pre>
  
  <p>Output (Project is called "Other"):</p>
  
  <pre><code>File does not exist: file:\F:\Development\CoolDirectory\Other\bin\Test
  </code></pre>