title: Java: How do I open a text file in test that is in src/main/resources?
body: <p>my project struture looks like</p>
  
  <pre><code>project/
         src/main/
                 java/ ...
                 resources/
                           definitions.txt
                 test/
                      CurrentTest.java
                 resources/ ...
  </code></pre>
  
  <p>In my test I need to open the <code>definitions.txt</code></p>
  
  <p>I do</p>
  
  <pre><code> @Test
   public void testReadDesiredDefinitions() throws PersistenceException, IOException {
          final Properties definitions = new Properties();
          definitions.load(new ResourceService("/").getStream("desiredDefinitions"));
          System.out.println(definitions);
   }
  </code></pre>
  
  <p>When I run this, I get </p>
  
  <pre><code>java.lang.NullPointerException
      at java.util.Properties$LineReader.readLine(Properties.java:418)
      at java.util.Properties.load0(Properties.java:337)
      at java.util.Properties.load(Properties.java:325)
  </code></pre>
  
  <p>How can I read this text file?</p>
  
  <p>Thanks</p>