Below code can be used to read the files from resources folder of a Spring Boot application.
InputStream is = MyClass.class.getResourceAsStream(PATH_TO_RESOURCE_FILE);
For example:
InputStream is = MyClass.class.getResourceAsStream("/static/pdf/Test.pdf");
If you are using JDK 8+, then it is best practice to use this along with try.
try (InputStream is = MyClass.class.getResourceAsStream(PATH_TO_RESOURCE_FILE)) { // Your code to process the file }