I have a J开发者_Go百科ava web application. Inside the WAR I have a folder containing configuration files for the application. I need to know the path of the folder in order to load the files at runtime.
I also need the solution to work in Tomcat and in WebSphere.
Thanks.
I would suggest placing the files under WEB-INF/classes
and simplying loading them from the classpath, not from the filesystem. This way, the path is always the same.
You can use something like:
InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream("path");
精彩评论