Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on Properities class

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Kishore Kumar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic