I have a Spring Boot App. I am trying to read few files that I have placed under main/resources folder. I see that Spring Boot automatically reads application.properties under resources folder. However it doesn't seem to read other xml / text files that I have placed under resources folder.
Source xslt = new StreamSource(new File("removeNs.xslt"));
ClassLoader classLoader = getClass().getClassLoader(); File file = new File(classLoader.getResource("removeNs.xslt").getFile());
This should work.
Thanks @Edwin for mentioning a more robust solution:
File file = new File(Thread.currentThread().getContextClassLoader().getResource("removeNs.xslt").getFile());