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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -