如何在使用 ResourceBundle API 获取的属性文件中转义大括号

发布于 2024-10-14 12:47:10 字数 249 浏览 11 评论 0原文

在属性文件中,我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

话少情深 2024-10-21 12:47:10
key=A: '{'{0}, {1}'}', B: '{'{2}, {3}'}'
key=A: '{'{0}, {1}'}', B: '{'{2}, {3}'}'
吃颗糖壮壮胆 2024-10-21 12:47:10

只需通过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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文