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

drupal - using views argument in the view tpl.php file -

php - Posting PHPBB Forum Thread/Post info in a website -

php - Add a blog by sending a mail to a certain emailadress -