This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question on Properities class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question on Properities class" Watch "Question on Properities class" New topic
Author

Question on Properities class

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486
Hello Ranchers,

I have heard that Properties class/file is very helpful whenver you want to add something new to existing,instead manipulating the java code, you can just add new things to properties file and that will reflected in your o/p when you compile java code.

Can someone please explain its use with example please.....
I will be thankful to you all.

Thanks in advance
Dinesh


Thanks<br />Dinesh
Kishore Kumar
Ranch Hand

Joined: Oct 15, 2007
Posts: 71
Hi,
I am giving a small example of how to read the properties file.
In the properties file, i am using Driverclass, Drierurl, username and password which are useful for obtainging database connection. I am reading the properties file through java code. So, later when you change the driver also, just change the properties file. ans Run the program, all the changes will be reflected in your program.




//Property.java


while running the above file use java -DFile="Path where you stored the file.props file"
 
jQuery in Action, 2nd edition
 
subject: Question on Properities class