Java MessageFormat - How can I insert values between single quotes?

前端 未结 5 1829
渐次进展
渐次进展 2020-12-05 09:03

I\'m having a problem using the java.text.MessageFormat object.

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

5条回答
  •  余生分开走
    2020-12-05 09:45

    Within a String, a pair of single quotes can be used to quote any arbitrary characters except single quotes. For example, pattern string "'{0}'" represents string "{0}", not a FormatElement. A single quote itself must be represented by doubled single quotes '' throughout a String. For example, pattern string "'{''}'" is interpreted as a sequence of '{ (start of quoting and a left curly brace), '' (a single quote), and }' (a right curly brace and end of quoting), not '{' and '}' (quoted left and right curly braces): representing string "{'}", not "{}".

    From: MessageFormat (Java Platform SE 8 )

提交回复
热议问题