Java MessageFormat - How can I insert values between single quotes?
<p>I'm having a problem using the java.text.MessageFormat object.</p>

<p>I'm trying to create SQL insert statements.   The problem is, when I do something like this:</p>

<pre><code>MessageFormat messageFormat = "insert into {0} values ( '{1}', '{2}', '{3}', {4} )";
Object[] args = { str0, str1, str2, str3, str4 };
String result = messageFormat.format(args);
</code></pre>

<p>I get this for the value of <code>result</code>:</p>

<pre><code>"insert into &lt;str0&gt; values ( {1}, {2}, {3}, &lt;str4&gt; )"
</code></pre>

<p>As you can see, the problem is that any of the target locations that are enclosed by single quotes do not get replaced by arguments.   I have tried using double single quotes like this: <code>''{1}''</code> and escaped characters like this: <code>\'{1}\'</code> but it still gives the same result. </p>

<p>edit: I forgot to mention that I also tried <code>'''{1}'''</code>.   The result is: <code>"insert into &lt;str0&gt; values ( '{1}', '{2}', '{3}', &lt;str4&gt; )"</code>.   It is keeping the original quotes around but still not inserting the values.</p>

<p>How can I resolve this issue?   For the record, I am using JDK 6u7.</p>
