Thanks all for responding. The most suitable approach for me is: InputStream is = this.getClass().getClassLoader().getResourceAsStream("myApp.properties");
I just put my file in the classes directory- that is what I would like. Sanjay --- Jacob Kjome <[EMAIL PROTECTED]> wrote: > That might work in most cases, but it won't find the > file in a container > that doesn't expand the .war archive. The following > will read it whether > in a directory structure or in a .war archive: > > InputStream is = > getServletContext().getResourceAsStream("/WEB-INF/myApp.properties"); > > > If the file exists in the same package as the class, > you can load it like this: > > InputStream is = > this.getClass().getResourceAsStream("myApp.properties"); > > I would think you could also do this to find it in > the classes directory: > > InputStream is = > this.getClass().getClassLoader().getResourceAsStream("myApp.properties"); > > > All those methods are independent of the filesystem. > > Jake > > At 11:38 AM 4/3/2002 -0500, you wrote: > >I place my properties files in the WEB-INF > directory and do the following to > >find them - > > > >String webInfFolder = > getServletContext().getRealPath("/WEB-INF") > > > >-----Original Message----- > >From: Sanjay Bahal [mailto:[EMAIL PROTECTED]] > >Sent: Wednesday, April 03, 2002 11:34 AM > >To: tomcat > >Subject: Working Directory > > > > > >I am trying to read a properties file from my > servlet. > >It always comes back saying file not found. I have > >tried placing the file in > >classes/web-inf/context-path. Ideally I would like > to > >lace it in my classes directory- How do I achieve > it. > >Thanks > >Sanjay > > > >__________________________________________________ > >Do You Yahoo!? > >Yahoo! Tax Center - online filing with TurboTax > >http://taxes.yahoo.com/ > > > >-- > >To unsubscribe: > <mailto:[EMAIL PROTECTED]> > >For additional commands: > <mailto:[EMAIL PROTECTED]> > >Troubles with the list: > <mailto:[EMAIL PROTECTED]> > > > >-- > >To unsubscribe: > <mailto:[EMAIL PROTECTED]> > >For additional commands: > <mailto:[EMAIL PROTECTED]> > >Troubles with the list: > <mailto:[EMAIL PROTECTED]> > __________________________________________________ Do You Yahoo!? Yahoo! Tax Center - online filing with TurboTax http://taxes.yahoo.com/ -- To unsubscribe: <mailto:[EMAIL PROTECTED]> For additional commands: <mailto:[EMAIL PROTECTED]> Troubles with the list: <mailto:[EMAIL PROTECTED]>