title: Correct way of reading a file in src/main/resources as string in a web application?
body: <p>I have a web application which has following structure (partial).</p>
  
  <pre><code>Project Name
     src/main/java
         com.package
             MainFile.java
     src/main/resources
         sample.xml
  </code></pre>
  
  <p>Now I want to read sample.xml from MainFile.java as a string.</p>
  
  <p>I tried using this method but got <code>NoSuchFileException</code></p>
  
  <pre><code>byte[] encoded = Files.readAllBytes(Paths.get("src/main/resources/sample.xml"));
  return new String(encoded, StandardCharsets.UTF_8);
  </code></pre>
  
  <p>Please suggest a solution to this issue.</p>