Gauls
Gauls

Reputation: 1965

Editing properties files w/o losing formatting

I have a properties (Java world) file with comments and key=value. I simply want to take backup of the file and edit few key=value. I need to edit the key in loop as the number of keys are not fixed and also the key names differ partly which is not a problem, but i am struggling to know how to maintain the format of the file (comments, spaces)?

 # ABC System Admin Database
       abc_jdbc.password=5667P7JiL7k221j+DmnVQ==

 # XYZ System Admin Database
       xyz_jdbc.password=489slP7JiL7k221j+LmnVQ==

and so on......

Upvotes: 2

Views: 727

Answers (1)

MarrLiss
MarrLiss

Reputation: 808

Properties from JDK does not remember previous state. You can use some other library for it, for example Commons Configuration

Upvotes: 3

Related Questions