Do resource bundles in Java support runtime string substitution?

前端 未结 8 662
夕颜
夕颜 2020-12-25 10:32

Can you do the following with a Java ResourceBundle?

In the properties file...

example.dynamicresource=You currently have {0} accounts.
8条回答
  •  醉梦人生
    2020-12-25 11:16

    I don't believe ResourceBundle can do that itself, but String can:

    String.format(bundle.getString("example.dynamicresource"), accountCount);
    

提交回复
热议问题