<p>If I have a Resource bundle property file:</p>

<p>A.properties:</p>

<pre><code>thekey={0} This is a test
</code></pre>

<p>And then I have java code that loads the resource bundle:</p>

<pre><code>ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale);
labels.getString("thekey");
</code></pre>

<p>How can I replace the {0} text with some value</p>

<pre><code>labels.getString("thekey", "Yes!!!");
</code></pre>

<p>Such that the output comes out as:</p>

<pre><code>Yes!!! This is a test.
</code></pre>

<p>There are no methods that are part of Resource Bundle to do this.  Also, I am in Struts, is there some way to use MessageProperties to do the replacement.</p>

[{'answer_id': 68075, 'author': 'user10544', 'author_id': 10544, 'author_profile': 'https://Stackoverflow.com/users/10544', 'pm_score': 5, 'selected': True, 'text': '<p>The class you\'re looking for is java.text.MessageFormat; specifically, calling</p>\n\n<pre><code>MessageFormat.format("{0} This {1} a test", new Object[] {"Yes!!!", "is"});\n</code></pre>\n\n<p>or</p>\n\n<pre><code>MessageFormat.format("{0} This {1} a test", "Yes!!!", "is");\n</code></pre>\n\n<p>will return</p>\n\n<pre><code>"Yes!!! This is a test"\n</code></pre>\n\n<p>[Unfortunately, I can\'t help with the Struts connection, although <a href="http://www.jguru.com/faq/view.jsp?EID=915891" rel="noreferrer">this</a> looks relevant.]</p>\n'}, {'answer_id': 68163, 'author': 'Lukáš Rampa', 'author_id': 10560, 'author_profile': 'https://Stackoverflow.com/users/10560', 'pm_score': 2, 'selected': False, 'text': '<p>There is the class <a href="http://struts.apache.org/1.2.7/api/org/apache/struts/util/MessageResources.html" rel="nofollow noreferrer">org.apache.struts.util.MessageResources</a> with various methods getMessage, some of them take arguments to insert to the actual message.</p>\n\n<p>Eg.:</p>\n\n<pre><code>messageResources.getMessage("thekey", "Yes!!!");\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/68018', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/10522/']