title: How to read a file from a Maven dependency project?
body: <p>I have two Maven projects A and B. B depends on A.</p>
  
  <p>In A, I have a file <code>someFile.txt</code> in the <code>src/main/resources</code> folder. </p>
  
  <pre><code>public class SomeAClass
  {
      public void someMethod()
      {
          final InputStream inputStream =
                  Thread.currentThread()
                          .getContextClassLoader()
                          .getResourceAsStream("someFile.txt");
          final List&lt;String&gt; lines = IOUtils.readLines(inputStream);
  
          ...
      }
  }
  </code></pre>
  
  <p>In A's tests, this works fine.</p>
  
  <p>Now imagine I want to use that same code in B, including the ability to read the data from <code>src/main/resources/someFile.txt</code>.</p>
  
  <p>Right now, calling <code>SomeAClass.someMethod()</code> from project B causes a NullPointerException and I suspect it's because <code>src/main/resources/someFile.txt</code> cannot be found.</p>
  
  <p>How can I change the code for getting the input stream for <code>src/main/resources/someFile.txt</code> so that it works both in A's unit tests and when executing B (B is a Spring Shell based console application) ?</p>