• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading Properties file

 
Shruthi Babu
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 33700
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Div,
You don't need to make them final, just immutable (unchangeable). Try something like this?

 
Shruthi Babu
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic