As specified in setComment method documentation, multiline comments can be provided using \n character.
A comment is identified by a path, so there can only be one comment for each path, this is the reason why the method is called setComment and not addComment, but in that comment you can provide multiple lines as you'd do in any String. This is only useful for BLOCK comments.
If you need to add a comment with several lines you have two equivalent approaches:
Build a single String with several lines using \n character and then use setComment.
As specified in setComment method documentation, multiline comments can be provided using
\n
character.A comment is identified by a path, so there can only be one comment for each path, this is the reason why the method is called setComment and not addComment, but in that comment you can provide multiple lines as you'd do in any String. This is only useful for
BLOCK
comments.If you need to add a comment with several lines you have two equivalent approaches:
\n
character and then usesetComment
.Or using a
StringBuilder
:setComment
for the first line and then add the following lines prefixing the result ofgetComment
.