简体   繁体   English

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

[英]How to escape curly braces in my properties file which is fetched using the ResourceBundle API

In properties file I am having a key=A: {{0}, {1}}, B: {{2}, {3}} . 在属性文件中,我有一个key=A: {{0}, {1}}, B: {{2}, {3}} I am expecting a string "A: {0, 1}, B: {1, 2}" . 我期待一个字符串"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. 错误java.lang.IllegalArgumentException:无法解析参数编号0,1发生。

key=A: '{'{0}, {1}'}', B: '{'{2}, {3}'}'

just run the properties file through native2ascii tool that comes with the JDK. 只需通过JDK附带的native2ascii工具运行属性文件。 it will do the work for you. 它会为你做的工作。 Or better use the JRCEditor 或者更好地使用JRCEditor

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

相关问题 如何逃避netbeans中的花括号 - how to escape curly braces in netbeans 如何在JSP页面中转义大括号 - How to escape curly braces in jsp page 如何在 Struts 1.2 中的 .properties 文件中转义大括号 - How to escape curly brackets in .properties file in Struts 1.2 在Javascript中使用Resourcebundle属性 - Using Resourcebundle Properties in Javascript 如何在属性文件中指定值,以便可以使用ResourceBundle#getStringArray检索它们? - How do I specify values in a properties file so they can be retrieved using ResourceBundle#getStringArray? 使用ResourceBundle将属性文件从一种语言翻译成另一种语言 - Translate the Properties File from one language to another using ResourceBundle 从JFileChooser获取file.properties并在ResourceBundle上使用它 - getting file.properties from JFileChooser and using it on ResourceBundle Java ResourceBundle.getBundle如何加载属性文件? - How does Java ResourceBundle.getBundle load properties file? 如何在JAVA中通过ResourceBundle将匈牙利字符用作属性文件中的键? - How to use Hungarian characters as a key in properties file with ResourceBundle in JAVA? 如何在javadoc内联标记中转义花括号,例如{@code}标记 - How do you escape curly braces in javadoc inline tags, such as the {@code} tag
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM