• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regarding relative and absolute path

 
aditya seth
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frnds...
i m working on web application.
In my application i have
web-inf with src folder in which abc is first package
My program is in...
package abc.def.ghi.jkl.mno.pqr;
i m writing my program in this pacjage.
public class myProgram
{
..
..
..
}
i want to know how to access the file(say myFile.txt) placed in folder which is at same level of web-inf?

thx in advance.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at ServletContext.getResource and ServletContext.getResourceAsStream.

This is exactly why they're there.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getResource(java.lang.String)
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getResourceAsStream is precisely what I was looking for when I came to the ranch today. It was right there in the first topic of the day! Thanks, Ben!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!