title: What would be a good use case of using resources directory in Java?
body: <p>When I want to load a file or asset(say an image) from file system into my program, I could either read the file directly from file system using something like </p>
  
  <pre class="lang-java prettyprint-override"><code>Files.readAllLines(Paths.get(fileName), StandardCharsets.UTF_8);
  </code></pre>
  
  <p>vs loading the file as a resource</p>
  
  <pre class="lang-java prettyprint-override"><code>getClass().getClassLoader().getResourceAsStream(fileName);
  </code></pre>
  
  <p>In Javadoc, Class#getResource() method, Javadoc specifies <code>Resources in named modules are subject to the rules for encapsulation specified in the {@code Module} {@link Module#getResourceAsStream getResourceAsStream} method and so this method returns {@code null} when the resource is a non-"{@code .class}" resource in a package that is not open to the caller's module.</code> but I somehow could not wrap my head around what would be the deciding factor for me to load a file as a resource or simply read it from file system.</p>