title: How to init file object in a java web application with the correct path
body: <p><a href="https://i.stack.imgur.com/Y0Nwt.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Y0Nwt.jpg" alt="enter image description here"></a></p>
  
  <p>So this is the folder structure of my web app. I am going to have some images uploaded here frequently which will be placed in <strong><em>images</em></strong> folder. Now what I am trying to do is to get a list of available images in a sub-foler of <strong><em>images</em></strong> folder. I am using the following code (located in BtsEvent.java and called from table.xhtml):</p>
  
  <pre><code>    List&lt;String&gt; lstFileNames =  new ArrayList&lt;String&gt;();
      // read all image files from folder
  
      File folder = new File("images/EventID1/");
      File[] listOfFiles = folder.listFiles();
  </code></pre>
  
  <p>and I get java.lang.NullPointerException exception. I think another method for getting file paths is required. How can I correctly init folder object?</p>