如何在使用 ResourceBundle API 获取的属性文件中转义大括号
在属性文件中,我有一个 key=A: {{0}, {1}}, B: {{2}, {3}}
。我期待一个字符串 "A: {0, 1}, B: {1, 2}"
。正在解析大括号内的数字。如何包含字符“{”而不绑定到任何值?我还尝试转义像“//{”这样的字符。即使我也无法得到预期的结果。出现错误 java.lang.IllegalArgumentException: can't parse argument number 0, 1 \ 。
In properties file I am having a key=A: {{0}, {1}}, B: {{2}, {3}}
. I am expecting a string "A: {0, 1}, B: {1, 2}"
. The numbers inside the curly braces are parsing. How can I include the character '{' without binding to any value? I also tried by escaping the character like this "//{". Even I couldn't get the expected result. An error java.lang.IllegalArgumentException: can't parse argument number 0, 1 \ occurs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需通过JDK自带的native2ascii工具运行properties文件即可。它会为你完成工作。或者更好地使用 JRCEditor
just run the properties file through native2ascii tool that comes with the JDK. it will do the work for you. Or better use the JRCEditor