Rakesh Juyal
Rakesh Juyal

Reputation: 36749

Can we have multiline comments in a Java properties file?

In a Java .properties file we can do single line comments with #.

Is there any way by which we can do multi-line comments?

Upvotes: 128

Views: 126236

Answers (8)

Luigi
Luigi

Reputation: 8847

.properties files do not have multiline comments.

Since JDK 1.5 Properties have XML support, and XML format supports multiline comments. See javadocs.

Upvotes: 10

zaboco
zaboco

Reputation: 2838

If you use Eclipse, you can select multiple lines and comment all with a shortcut (Ctrl+/ by default). Same shortcut uncomments the lines, but you have to pay attention no to select any empty line, which will cause the non-empty ones to get commented more than once.

These apply to Eclipse, but I guess many IDE:s and some editors offer similar functionality.

Upvotes: 44

san
san

Reputation: 98

We can use Ctrl+/ to comment multiple lines in properties file. But it will put # for blank line also.

Upvotes: 3

KristoferRobin
KristoferRobin

Reputation: 57

If you are using Eclipse there is this shortcut Ctrl+Shift+A that turns on selecting a column, so you can just drag through all the rows you need to comment and add # (this will add it to all rows). It will be the same when you want to delete the #. To turn off the column selecting mode you have to again press Ctrl+Shift+A.

Upvotes: 0

Jinish Davis
Jinish Davis

Reputation: 27

Select the content to comment out and press ctrl+/ on the eclipse editor

Upvotes: 1

user1872213
user1872213

Reputation: 17

single line comment using #

multiline comment using <!-- -->

Upvotes: -9

FrederikH
FrederikH

Reputation: 139

I have made a class that handles comments in properties. Both general header comments and comments for individual properties.

Have a look at : CommentedProperties JavaDoc

The jar file can be downloaded here : Download jar file from sourceforge

Upvotes: 5

Adrian Smith
Adrian Smith

Reputation: 17553

Unfortunately not! Java properties file only have single line # comments.

Upvotes: 188

Related Questions