Can I put comments between or after multi-line properties in a Java properties file?

I have 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 do something like this:

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

Clarification: I supply a config for a web service that I don’t own, so I can’t use one of the extensions for the property format, for example bracket-properties

+7
java configuration
source share
2 answers

Unfortunately, this is not possible since Java property files can have only one line of # comments .

However, you may be aware that you can also define properties in XML format, and the XML syntax allows you to enter multi-line comments .

If you decide to give XML a chance, you will need to call Properties#loadFromXML(InputStream) to load the XML Properties File.

+7
source share

It's impossible. The comment must appear on the line by itself and consists of an optional space followed by a "#" or "!" and then arbitrary text to the end of the line. The full specification of Java property files can be found in the Javadoc documentation for the load(java.io.Reader reader) method load(java.io.Reader reader) of the java.util.Properties class .

0
source share

All Articles