java删除斜杠文件_如何在java属性中删除转义额外斜杠(How to remove escape extra slash in java properties)...

如何在java属性中删除转义额外斜杠(How to remove escape extra slash in java properties)

我使用以下内容将一些值写入.properties文件。 这段代码适用于一个小问题,写入的值就是这样

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

使用额外的斜线,这不起作用。 对于我的生活,我无法摆脱额外的斜线。 我试过URLEncode.encode但没有去。

谢谢你的帮助。

I am using the following to write some values to a .properties file. 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.

Thanks for any help.

原文:https://stackoverflow.com/questions/29414485

2019-12-07 14:12

满意答案

没关系。 这就是写入属性文件的意思 。

键和元素字符#,!,=和:使用前面的反斜杠写入,以确保它们已正确加载。

从属性文件中读取值的代码将适当地取消它。

That's fine. That's how it's meant to be written to the properties file.

From the Properties.store documentation:

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.

2015-04-02

相关问答

另外,请参考javadoc上的Property类的load(Reader reader)方法 在load(Reader reader)方法文档中说 键包含从第一个非空格字符开始的行中的所有字符,直到但不包括除行终止符之外的第一个未转义的'=' , ':'或空白字符。 所有这些密钥终止字符可以通过用前面的反斜杠字符进行转义而被包括在密钥中; 例如, \:\=

将是双字符键":=". 可以使用\r和\n转义序列包括行终止符字符。 钥匙之后的任何空格都被跳过; 如果键后的第一个非空白字符为'='或':...

根据这种性能比较: https : //jsperf.com/dictionary-contains-key 最有效的方法是: for(attr in newItem) {

if(defaults[attr] === undefined)

delete newItem[attr];

}

According to this performance comparison: https://jsperf.com/dictionary-contains-key The most effici...

如果你想从android中删除转义斜杠,你可以尝试这个.... String receivedString = "{\"property_type\":[\"residential\"],\"status\":[\"active\"],\"category\":[\"sale\"],\"page_size\":8,\"cur_page\":1}";

String changedString = receivedString.replaceAll("\"", "\"");

Log....

考虑使用StringUtils。 如果有一个方法来逃避像你的输入。 http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringEscapeUtils.html#escapeJava(java.lang.String) Consider using StringUtils. If has a method to escape input like yours. http://commons.apache.org/lang...

您不需要在Java中作为语言或正则表达式转义正斜杠。 还要注意这样的块: if (condition) {

return true;

} else {

return false;

}

更加紧凑和可读性如下: return condition;

所以在你的情况下,我相信你的方法应该是这样的: public boolean checkDate(String dateToCheck) {

return dateToCheck.matches("[0-9][0-9]/[0-9]...

我不知道为什么你想这样做,但下面的代码将为你工作。 var url = 'http://example.net/hi-how-are-you';

var pos = url.lastIndexOf('/');

url = url.substring(0,pos)+'//'+url.substring(pos+1);

console.log(url); I am not sure why you want to do that, but following code will work for...

您应该从重定向路径的末尾删除额外的尾部斜杠: return 301 https://$server_name$request_uri;

You should remove the extra trailing slash from the end of your redirection path: return 301 https://$server_name$request_uri;

额外的属性应该通过ext创建,但是通过project实例引用而不需要任何实例: project.dir或dir ,所以对脚本的第一个更改将是: ext {

dir = null

}

task init << {

build()

}

task buildAll(type: Exec){

workingDir dir // ext.dir -> dir

commandLine 'cmd', '/c', "echo %JAVA_HOME%"

}

def build(){

ext...

您无法从属性文件中删除\的使用,因为这是定义要实现的属性文件的方式。 来自Javadoc for Properties 所有这些密钥终止字符都可以通过使用前面的反斜杠字符转义它们来包含在密钥中; 例如, \:\=

这条线 query=select * from users where id = 1

无效,因为它包含两个未转义的=字符。 第二个需要逃脱。 您可以以不同方式实现属性以不需要它,但它不是标准的属性文件。 存储属性的其他方法是XML,JSON和YAML。 我更喜欢YAML,它通常更简单...

没关系。 这就是写入属性文件的意思 。 从Properties.store文档: 键和元素字符#,!,=和:使用前面的反斜杠写入,以确保它们已正确加载。 从属性文件中读取值的代码将适当地取消它。 That's fine. That's how it's meant to be written to the properties file. From the Properties.store documentation: The key and element characters #, !, =,...

相关文章

1. 描述 尝试用多种方法读取属性文件。 测试打印系统属性; 测试读取、写入用户属性文件; 测试

...

+ - && || ! ( ) { } [ ] ^ " ~ * ? : \

...

If the configuration directory for a Solr core cont

...

我把log4j.properties文件放到"WEB-INF\classes"目录

...

我们现有的Hadoop集群已经运行了一段时间了 由于集群中的服务器分布在2个不同的机房,受跨机房带宽的

...

Vibrations in the ground are a poorly understood bu

...

删除集合中的文档,使用命令 db.集合名称.remove({删除条件}),例如,db.c1.remov

...

1、开发环境集成 1)在myeclipse环境集成 在windows-properties-tomca

...

Java 集合框架 早在Java 2中之前,Java就提供了特设类。比如:Dictionary,

...

最新问答

如果启用了复制处理程序,请确保将其置于其中一个安全角色之后。 我见过人们做的另一件事是在不同的端口上运行admin。 最好在需要auth的页面上使用SSL,这样你就不会发送明确的密码,因此管理和复制将发生在8443上,而常规查询将在8080上发生。 如果您要签署自己的证书,请查看此有用的SO页面: 如何在特定连接上使用不同的证书? I didn't know that /admin was the context for SOLR admin because /admin does not re

第一:在您的样本中,您有: 但是你在询问 //td[@class=‘CarMiniProfile-TableHeader’] (注意TableHeader中的大写'T')。 xpath区分大小写。 第二:通过查询// td [@ class ='CarMiniProfile-TableHeader'] / td,你暗示你在外部td中有一个'td'元素,而它们是兄弟姐妹。 有很多方法可以在这里获得制作和模型

这是你的答案: http://jsfiddle.net/gPsdk/40/ .preloader-container { position: absolute; top: 0px; right: 0px; bottom: 0px; left: 0px; background: #FFFFFF; z-index: 5; opacity: 1; -webkit-transition: all 500ms ease-out;

问题是,在启用Outlook库引用的情况下, olMailItem是一个保留常量,我认为当您将Dim olMailItem as Outlook.MailItem ,这不是问题,但是尝试设置变量会导致问题。 以下是完整的解释: 您已将olMailItem声明为对象变量。 在赋值语句的右侧,在将其值设置为对象的实例之前,您将引用此Object 。 这基本上是一个递归错误,因为你有对象试图自己分配自己。 还有另一个潜在的错误,如果之前已经分配了olMailItem ,这个语句会引发另一个错误(可能是

我建议使用wireshark http://www.wireshark.org/通过记录(“捕获”)设备可以看到的网络流量副本来“监听”网络上发生的对话。 当您开始捕获时,数据量似乎过大,但如果您能够发现任何看起来像您的SOAP消息的片段(应该很容易发现),那么您可以通过右键单击并选择来快速过滤到该对话'关注TCP Stream'。 然后,您可以在弹出窗口中查看您编写的SOAP服务与Silverlight客户端之间的整个对话。 如果一切正常,请关闭弹出窗口。 作为一个额外的好处,wireshar

Android默认情况下不提供TextView的合理结果。 您可以使用以下库并实现适当的aligntment。 https://github.com/navabi/JustifiedTextView Android Does not provide Justified aligntment of TextView By default. You can use following library and achieve proper aligntment. https://github.com/

你的代码适合我: class apples { public static void main(String args[]) { System.out.println("Hello World!"); } } 我将它下载到c:\ temp \ apples.java。 以下是我编译和运行的方式: C:\temp>javac -cp . apples.java C:\temp>dir apples Volume in drive C is HP_PAV

12个十六进制数字(带前导0x)表示48位。 那是256 TB的虚拟地址空间。 在AMD64上阅读wiki(我假设你在上面,对吗?)架构http://en.wikipedia.org/wiki/X86-64 12 hex digits (with leading 0x) mean 48 bits. That is 256 TB of virtual address space. Read wiki on AMD64 (I assume that you are on it, right?) ar

这将取决于你想要的。 对象有两种属性:类属性和实例属性。 类属性 类属性对于类的每个实例都是相同的对象。 class MyClass: class_attribute = [] 这里已经为类定义了MyClass.class_attribute ,您可以使用它。 如果您创建MyClass实例,则每个实例都可以访问相同的class_attribute 。 实例属性 instance属性仅在创建实例时可用,并且对于类的每个实例都是唯一的。 您只能在实例上使用它们。 在方法__init__中定

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值