9

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

B Johnson
  • 2,408
  • 3
  • 20
  • 32

2 Answers2

8

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.

Paulo Merson
  • 13,270
  • 8
  • 79
  • 72
anubhava
  • 761,203
  • 64
  • 569
  • 643
1

This is not possible. A comment must appear on a line by itself, and it consists of optional white space followed by the "#" or "!" character, and then arbitrary text up to the end-of-line. You can find the full specification of Java Properties files in the Javadoc documentation for the load(java.io.Reader reader) method of the java.util.Properties class.

Ciaran McHale
  • 2,126
  • 14
  • 21