我们可以在 Java 属性文件中有多行注释吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4156600/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can we have multiline comments in a Java properties file?
提问by Rakesh Juyal
In a Java .properties
file we can do single line comments with #
.
在 Java.properties
文件中,我们可以使用#
.
Is there any way by which we can do multi-line comments?
有什么办法可以做多行注释吗?
采纳答案by Adrian Smith
Unfortunately not! Java properties file only have single line #
comments.
不幸的是没有!Java 属性文件只有单行#
注释。
回答by zaboco
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.
如果您使用 Eclipse,您可以选择多行并使用快捷方式(默认为Ctrl+ /)进行注释。相同的快捷方式取消注释行,但您必须注意 no 选择任何空行,这将导致非空行被多次注释。
These apply to Eclipse, but I guess many IDE:s and some editors offer similar functionality.
这些适用于 Eclipse,但我猜许多 IDE:s 和一些编辑器提供了类似的功能。
回答by Luigi R. Viggiano
回答by FrederikH
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
看看:CommentedProperties JavaDoc
The jar file can be downloaded here : Download jar file from sourceforge
jar 文件可以在这里下载:从 sourceforge 下载 jar 文件
回答by user1872213
single line comment using #
单行注释使用 #
multiline comment using <!-- -->
多行注释使用 <!-- -->
回答by KristoferRobin
If you are using Eclipse there is this shortcut Ctrl+Shift+Athat 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.
如果您使用的是 Eclipse,则有此快捷方式Ctrl+ Shift+A可以打开选择列,因此您只需拖动需要注释和添加的#
所有行(这会将其添加到所有行)。当您要删除#
. 要关闭列选择模式,您必须再次按 Ctrl+ Shift+ A。
回答by Jinish Davis
Select the content to comment out and press ctrl+/on the eclipse editor
选择要注释掉的内容,在eclipse编辑器上按ctrl+/
回答by san
We can use Ctrl+/to comment multiple lines in properties file. But it will put #
for blank line also.
我们可以使用Ctrl+/来注释属性文件中的多行。但它也会#
为空行。
回答by krsna
We can use Ctrl+/ to comment multiple lines in properties file.
我们可以使用 Ctrl+/ 在属性文件中注释多行。
回答by Abhishesh
Yes you can comment multiline in java properties file by using shortcut key Ctrl+/.
是的,您可以使用快捷键 Ctrl+/ 在 java 属性文件中注释多行。