aspose file tools*
The moose likes Java in General and the fly likes Is is possible to read values from a properties file but have those variables be static? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is is possible to read values from a properties file but have those variables be static?" Watch "Is is possible to read values from a properties file but have those variables be static?" New topic
Author

Is is possible to read values from a properties file but have those variables be static?

divya kundapur
Ranch Hand

Joined: Aug 21, 2007
Posts: 110
Hi,

I have a .properties file which i will be reading in a class. I need to get the values from the properties file as static ,Is is possible to read values from a properties file but have those variables be static? How can i do it.

SCJP - 5.0
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Just declare your Properties variable as a static variable. As such, it would probably be best to load your the file in the a static initializer block:



Alternatively, you could have a static method that loads the properties file and then in your constructor do a lzay init of the properties file:



divya kundapur
Ranch Hand

Joined: Aug 21, 2007
Posts: 110
thanks Mark, will be trying that
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is is possible to read values from a properties file but have those variables be static?