简体   繁体   English

如何在Java属性中删除转义多余的斜杠

[英]How to remove escape extra slash in java properties

I am using the following to write some values to a .properties file. 我正在使用以下内容将一些值写入.properties文件。 this code works with one small problem the value that gets written is like this 这段代码解决了一个小问题,写入的值是这样的

C\:/MyDir/MyDir2/Downloads/SomeOrder.txt

With an extra slash, this does not work. 加上一个斜杠,这是行不通的。 For the life of me I can't get rid of the extra slash. 对于我的一生,我无法摆脱多余的斜线。 I have tried URLEncode.encode but no go. 我已经尝试过URLEncode.encode,但没有成功。

Thanks for any help. 谢谢你的帮助。

That's fine. 没关系。 That's how it's meant to be written to the properties file. 就是将其写入属性文件的方式。

From the Properties.store documentation: Properties.store文档中:

The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded. 键和元素字符#,!,=和:前面带有反斜杠,以确保正确加载它们。

The code that reads the value from the properties file will unescape it appropriately. 从属性文件中读取值的代码将适当地对其进行转义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM