This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes calling properties files from static class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "calling properties files from static class" Watch "calling properties files from static class" New topic

calling properties files from static class

Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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\\")));

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?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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.

Rahul Bhattacharjee
LinkedIn - Blog
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: calling properties files from static class
It's not a secret anymore!