| Author |
Loading Properties file
|
Shruthi Babu
Ranch Hand
Joined: May 04, 2007
Posts: 54
|
|
I have some values in my property files for example file_path = "file location" I need to load these properties file and store them in java beans so that i can use them through out the porgram. My concern is I need to make these values final as they are no gonna be changed. how to achieve this ? Is this a good approach or is there a better way to do it. Since i wanted to make it final the issue I am facing is The properties file need to loaded initially before I assign it to the final class variables need to do something like this public static final String FILE_PATH = properties.getProperty("TXT_FILE_PATH) ; how to load the properties before this class variables initialization.The file name for the porperties to be loaded need to be passed as parameter. I was not able to use static block as i was not able to pass the parameter.
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26173
|
|
Div, You don't need to make them final, just immutable (unchangeable). Try something like this?
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Shruthi Babu
Ranch Hand
Joined: May 04, 2007
Posts: 54
|
|
Thanks for the reply.. I need to pass the properties file name from some other class to this props class how can it be achieved? since we are calling a no-arg constructor?
|
 |
 |
|
|
subject: Loading Properties file
|
|
|