我可以在一个java MessageFormat中摆脱大括号吗? [英] Can I escape braces in a java MessageFormat?

查看:148
本文介绍了我可以在一个java MessageFormat中摆脱大括号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在一个java MessageFormat中输出一些大括号。例如,我知道以下内容不起作用:

  MessageFormat.format(public {0} get {1}() return {2};} \\\
\\\
,type,upperCamel,lowerCamel);

有没有办法绕过return {2}周围的大括号?

解决方案

您可以将它们放在单引号中,例如

 '{'return {2};'}'

请参阅 here 了解更多详情。


I want to output some braces in a java MessageFormat. For example I know the following does not work:

MessageFormat.format("  public {0} get{1}() {return {2};}\n\n", type, upperCamel, lowerCamel);

Is there a way of escaping the braces surrounding "return {2}"?

解决方案

You can put them inside single quotes e.g.

'{'return {2};'}'

See here for more details.

这篇关于我可以在一个java MessageFormat中摆脱大括号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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