• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

calling properties files from static class

 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a simple static class for creating a db connection, and need to be able to call a properties file with the db details in it from this class.

At the moment it uses a very basic:-

Properties props = new Properties();
props.load( new FileInputStream(new File("C:\\Java\\Tomcat \\webapps\\dbinit.properties")));

method, which is fine for a static location of the file, but a bit ugly.

I want to move the properties file into the WebApp (under /class folder I think) so need to know how to call the file from there?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This has been taken from Jaikiran Pai's (One of the bartenders in Javaranch) blog.It explains as how can you read a properties file from within a web application.
 
Screaming fools! It's nothing more than a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic