Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I put comments in between or after multiline properties in a Java Properties file?

I've got a properties configuration file with properties that have many values separated by commas. I want to put comments next to some of them, but it seems that this is not possible?

I want to be able to do something like this:

property: value1,\
    value2,\
    ...
    value44,\ 
    value45,\ 
    # value45 comment
    ...
    value89,\ # another comment
    value90

Clarification: I'm supplying the config to a web service I don't own, so I can't use one of the extensions to the properties format like bracket-properties

like image 209
B Johnson Avatar asked Sep 09 '13 18:09

B Johnson


1 Answers

Unfortunately, it's not possible as Java properties files can have only single line # comments.

However, you might be aware that you can also define properties in xml format and the XML syntax will let you enter multi-line comments.

If you decide to give XML a chance then you will need to call Properties#loadFromXML(InputStream) to load your XML property file.

like image 197
anubhava Avatar answered Sep 18 '22 19:09

anubhava