File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Modifying Property Files.

 
Nikhil Jain
Ranch Hand
Posts: 389
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can property file be modified programatically?
 
Sudarshan Chakrabarty
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well a Property file is just a text file after all. Just as you can read from a property file so can you write to a property file.
You can always modify a file using the FileWriter programatically.
 
arulk pillai
Author
Ranch Hand
Posts: 3380
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But once you programmatically modify it, need to reload the data to your memory (e.g. Properties) for those changes to take effect or need to restart the application.
 
Gamini Sirisena
Ranch Hand
Posts: 378
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use the Properties class to load and store a property file.

look at the load and store methods of this class. The properties class is basically a Hashtable and you can put and remove elements from it.

The only problem might be that you will lose any comments already in the property file. I believe the Jakarta Commons project has an implementation that supports comments.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic