Properties file stored in WEB-INF/classes.There are numerous ways to read properties files, but I'd like to knowwhat your opinions are on the best way to read from the WEB-INF/classes directory given that I could deploy my war file to any serveron any platform not knowing how a server is configured, i.e. with itsreal paths etc.
|
|
0
|
|
|
|
Reply
|
mark.dundon (26)
|
10/7/2007 8:23:56 AM |
|
On Oct 7, 1:23 am, Dundonald <mark.dun...@gmail.com> wrote:
> Properties file stored in WEB-INF/classes.
>
> There are numerous ways to read properties files, but I'd like to know
> what your opinions are on the best way to read from the WEB-INF/
> classes directory given that I could deploy my war file to any server
> on any platform not knowing how a server is configured, i.e. with its
> real paths etc.
getResourceAsStream() should give you the resouece that is in WEB-INF/
classes.
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)
-cheers,
Manish
|
|
0
|
|
|
|
Reply
|
Manish
|
10/7/2007 9:52:21 AM
|
|
Dundonald wrote:>> Properties file stored in WEB-INF/classes.>>>> There are numerous ways to read properties files, but I'd like to know>> what your opinions are on the best way to read from the WEB-INF/>> classes directory given that I could deploy my war [sic] file to any server>> on any platform not knowing how a server is configured, i.e. with its>> real paths etc.Manish Pandit wrote:> getResourceAsStream() should give you the resouece that is in WEB-INF/> classes.> > http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)(Also available from java.lang.Class.)<http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)>will do the same thing rooted at the application context.> Returns the resource located at the named path as an InputStream object.....> The path must begin with a "/" and is interpreted as relative to the current context root.....> This method is different from java.lang.Class.getResourceAsStream, > which uses a class loader. > This method allows servlet containers to make a resource available to a servlet from > any location, without using a class loader.-- Lew
|
|
0
|
|
|
|
Reply
|
Lew
|
10/7/2007 3:54:51 PM
|
|