[jboss-user] [Beginners Corner] - Re: How to access property files

jaikiran do-not-reply at jboss.com
Mon Nov 20 02:45:58 EST 2006


anonymous wrote : prop.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(PROP_FILE_NAME));

I usually do it this way, whenever i am loading a properties file:

 prop.load(this.getClass().getClassLoader().getResourceAsStream(PROP_FILE_NAME)); 

Assuming that the  PROP_FILE_NAME is just the name of the file and not the path, then that file should be present directly inside the war/ear/jar. If the PROP_FILE_NAME is something like "/conf/myprops/someprop.properties" then this is how  the directory structure will look like:


  | myApp.war
  |  |
  |  |------------ META-INF
  |  |
  |  |
  |  |------------- conf
  |  |                  |------ myprops
  |  |                                |------------ someprop.properties
  |  |
  |  |------------- WEB-INF
  |  |                    |--------- classes
  |  


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3987226#3987226

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3987226



More information about the jboss-user mailing list