title: Read file from /src/main/resources/
body: <p>I am trying to do a web application and have a problem:
  I don't know how to open a text file with Java that is saved in the resource folder:</p>
  
  <p><img src="https://i.stack.imgur.com/cDPAx.png" alt="text file saved in the resource folder"></p>
  
  <pre><code> String relativeWebPath ="/src/main/resources/words.txt";  //Import der des Textdoumentes
   String absoluteDiskPath = getServletContext().getRealPath(relativeWebPath);
   File f = new File(absoluteDiskPath);
  </code></pre>
  
  <p>(The file words.txt)</p>
  
  <p>As you can see on the image I am trying to access words.txt but it isn't working. Any ideas?</p>