java - How can I read file from classes directory in my WAR? -
i need read text file classpath in java war application. how can read inputstream. file located in /web-inf/classes/ folder, when use following code, returns null.
inputstream input = servletcontext.getclass().getclassloader().getresourceasstream("my_filename.txt");
prefix forward slash denote root of classpath:
getresourceasstream("/my_filename.txt")
alternatively, can use serlvetcontext.getresourceasstream(..)
looks resources relative context root. classes /web-inf/classes
.
Comments
Post a Comment