title: How to get files from resources folder. Spring Framework
body: <p>I'm trying to unmarshal my xml file:</p>
  
  <pre><code>public Object convertFromXMLToObject(String xmlfile) throws IOException {
      FileInputStream is = null;
      File file = new File(String.valueOf(this.getClass().getResource("xmlToParse/companies.xml")));
      try {
          is = new FileInputStream(file);
          return getUnmarshaller().unmarshal(new StreamSource(is));
      } finally {
          if (is != null) {
              is.close();
          }
      }
  }
  </code></pre>
  
  <p>But I get this errors:
  java.io.FileNotFoundException: null (No such file or directory)</p>
  
  <p>Here is my structure:</p>
  
  <p><a href="https://i.stack.imgur.com/nfhZa.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nfhZa.png" alt="enter image description here"></a></p>
  
  <p>Why I can't get files from resources folder? Thanks.</p>
  
  <p><strong>Update.</strong></p>
  
  <p>After refactoring,</p>
  
  <p>URL url = this.getClass().getResource("/xmlToParse/companies.xml");
          File file = new File(url.getPath());</p>
  
  <p>I can see an error more clearly:</p>
  
  <p>java.io.FileNotFoundException: /content/ROOT.war/WEB-INF/classes/xmlToParse/companies.xml (No such file or directory)</p>
  
  <p>It tries to find WEB-INF/classes/ 
  I have added folder there, but still get this error :(</p>
  
  <p><a href="https://i.stack.imgur.com/8UQ7s.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8UQ7s.png" alt="enter image description here"></a></p>