Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Nullpointer when reading a directory  RSS feed

 
Ong Vua
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application (WAR) and a directory called testdir under the WEB-INF\classes directory. I want to loop thru all the properties files inside this directory and for each one, I want to read each one and process it.

Inside my Java program, I have the following code to read the directory but it gave me back nullpointer

File bpelDir = new File("testdir ");

Here's the directory structure. The java program resides in the com\abc directory

WEB-INF\classes\testdir\
WEB-INF\classes\com\abc\

Thanks,
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try giving the absolute path like "C:\\WEB-INF\\" and all.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, try using ServletContext.getRealPath instead:
That will also work when you move the web application to a server with a different folder structure.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!