如何在属性文件的键中转义特殊字符? [英] How to escape special characters in the key of properties file?
问题描述
.properties文件中有一个 key = value
属性:
I've got a key = value
property in the .properties file:
give names: (1) code = xxx
...但是当我尝试要获取该密钥,它将引发错误:
... but when I tried to get that key, it threw an error:
在代码下未找到消息给出名称:(1)code = xxx
No message found under code give names: (1) code = xxx
我尝试使用 \
来转义空格,但是没有用。
I tried escaping the whitespace with \
but it didn't work.
我是否需要转义:
,(
和)
字符?
Do I need to escape :
,(
, and )
characters as well?
推荐答案
您可以签出:http://docs.oracle.com/javase/7 /docs/api/java/util/Properties.html#load(java.io.Reader)
有关java如何解释属性文件的信息。最相关的部分是:
For info on how java interprets a properties file. The most relevant part is:
键包含该行中的所有字符,从第一个非空白字符开始,直至,但不包括第一个未转义的'=',':'或除行终止符之外的空白字符。
The key contains all of the characters in the line starting with the first non-white space character and up to, but not including, the first unescaped '=', ':', or white space character other than a line terminator.
这篇关于如何在属性文件的键中转义特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!