title: What is the path to resource files in a Maven project?
body: <p>In my Maven project, I have the following code in the main method:</p>
  
  <pre><code>FileInputStream in = new FileInputStream("database.properties");
  </code></pre>
  
  <p>but always get a file not found error.</p>
  
  <p>I have put the file in src/main/resources and it is properly copied to the target/classes directory (I believe that is the expected behavior for Maven resources) but when actually running the program  it seems it can never find the file.  I've tried various other paths:</p>
  
  <pre><code>FileInputStream in = new FileInputStream("./database.properties");
  FileInputStream in = new FileInputStream("resources/database.properties");
  </code></pre>
  
  <p>etc. but nothing seems to work.</p>
  
  <p>So what is the proper path to use?</p>
  
  <hr>
  
  <p>Based on "disown's" answer below, here was what I needed:</p>
  
  <pre><code>InputStream in = TestDB.class.getResourceAsStream("/database.properties")
  </code></pre>
  
  <p>where <code>TestDB</code> is the name of the class.</p>
  
  <p>Thanks for your help, disown!</p>