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