Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding comments in a properties file line by line

This is something which I want to do in properties file

#Comments about key Value pair 1
Key_1=value_1


#Comments about key Value pair 2
Key_2=value_2

#Comments about key Value pair 3
Key_3=value_3

Right now what I am able to do with my file is

#OMG, It works!
#Mon Oct 14 01:22:10 IST 2013
Key_1=Value_1
Key_2=Value_2

Is there any way of doing such a thing

like image 656
The_Lost_Avatar Avatar asked Oct 13 '13 19:10

The_Lost_Avatar


1 Answers

You can use the Apache Commons Configuration to write and read Properties files, specifically the setComment() function in a PropertiesConfigurationLayout which allows you to specify a comment for each property.

Note that above links refer to Commons Configuration v1.x, while v2.0 has been released in the meantime, which has different package names.

like image 67
jmiserez Avatar answered Oct 02 '22 02:10

jmiserez