gpt4 book ai didi

Java:可以在属性文件中换行吗?

转载 作者:IT老高 更新时间:2023-10-28 11:25:17 26 4
gpt4 key购买 nike

是否可以在 Java 属性文件的下一行继续一个长字符串?

例如,不知何故

myStr=Hello
World

当我得到 getProperty("myStr") 时,它会返回“Hello World”?

最佳答案

行尾的反斜杠可让您跨越多行,并且忽略行首的空格:

myStr = Hello \
World

注意:反斜杠必须在行尾;它必须是最后一个字符,后面不能有空格,等等。

Java docs这么说吧:

A logical line holds all the data of a key-element pair, which may be spread out across several adjacent natural lines by escaping the line terminator sequence with a backslash character \.

...

If a logical line is spread across several natural lines, the backslash escaping the line terminator sequence, the line terminator sequence, and any white space at the start of the following line have no affect on the key or element values.

关于Java:可以在属性文件中换行吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5576164/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com