File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
calling properties files from static class
Kevin P Smith
Joined: Feb 18, 2005
Jul 24, 2007 08:30:00
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();
(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?
Joined: Nov 29, 2005
Jul 24, 2007 08:52:00
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.
I agree. Here's the link:
subject: calling properties files from static class
Loading resource in static method
How to put some code in one spot, rather than needing it in multiple classes and methods
Is is possible to read values from a properties file but have those variables be static?
static properties file
Data class and server code
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015