[英]Properties file escape a value
I've looking through How to escape the equals sign in properties files but didn't find my answer. 我一直在研究如何在属性文件中转义等号,但没有找到我的答案。
I have a Java Properties File
that includes sets such as: 我有一个
Java Properties File
,其中包含诸如以下的集合:
SOME_KEY = SOME_VALUE
This is normal. 这很正常。 However, some of the values actually contain escape/control characters, such as URL's.
但是,某些值实际上包含转义/控制字符,例如URL。 This properties file is to be hand edited by a user on a rare occasion.
该属性文件很少由用户手动编辑。 I want the user to be able to simply paste in a URL and not worry about special rules, etc.
我希望用户能够简单地粘贴URL,而不必担心特殊规则等。
So I have this showing in my file now: 所以现在我的文件中显示了这个:
SOME_KEY = http://www.example.com/something.asp?some=
where some=
is the base of dynamic URL where something after the =
will cause the URL to respond differently. 其中
some=
是动态URL的基础,其中=
后的某些内容将导致URL响应不同。
From reading http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html it doesn't seem to make mention of needing to escape any escape/control characters after the first unescaped =
or :
is encountered, but I need/want to make sure. 从阅读http://docs.oracle.com/javase/6/docs/api/java/util/Properties.html来看,似乎没有提到需要在第一个未转义的
=
或之后转义任何转义/控制字符。 :
,但是我需要/想要确定。
I know that if my KEY
had one of those characters present, then it would have to be escaped otherwise it'd be misread... such as: 我知道,如果我的
KEY
存在这些字符之一,则必须将其转义,否则将被误读...,例如:
SOME\=KEY = SOME_VALUE
Would make for a literal SOME=KEY
as the key value. 将使文字
SOME=KEY
作为键值。
In this above situation, excluding the obvious escaping of the KEY
, is it necessary to hand-escape the values? 在上述情况下,除了明显的
KEY
转义之外,是否有必要手动转义值?
After the first =
without escape, no. 在第一个
=
没有逃脱,否。
If you use eclipse, you might want install the JBoss Tools Properties Editor . 如果使用eclipse,则可能需要安装JBoss工具属性编辑器 。 You not need to worry about escaping values manually as you mention
SOME=KEY
or Unicode. 提到
SOME=KEY
或Unicode时,您不必担心手动转义值。 However, the pluging escapes the characters to avoid reading and coding problems. 但是,该插入会转义字符以避免阅读和编码问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.