如何在属性文件的关键字中转义特殊字符 [英] How to escape special characters in the key of properties file

查看:131
本文介绍了如何在属性文件的关键字中转义特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用属性(key = value),如在属性文件
中给出名称:(1)code = xxx
,但是当我试图获得该密钥正在给出错误在代码中找不到消息给出名称:(1)code = xxx

I am using a property(key = value) like give names: (1) code = xxx in the properties file but when i tried to get that key it is giving error as "No message found under code give names: (1) code = xxx

我尝试使用 \ ,但它不会工作,我需要逃避字符也请。建议如何继续

I tried it by escaping the whitespace with \ but it wont worked. do I need to escape :,(, and ) characters also. Please suggest how to proceed

谢谢

推荐答案

您可以查看: 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:


该键包含从第一个非空白字符开始的行中的所有字符,直到但不包括fir st unescaped'=',':'或除行终止符之外的空格字符。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆