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

前端 未结 5 1815
渐次进展
渐次进展 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:46

    I just tried double quotes and it worked fine for me:

    MessageFormat messageFormat = new MessageFormat("insert into {0} values ( ''{1}'', ''{2}'', ''{3}'', {4} )");
    Object[] args = {"000", "111", "222","333","444","555"};
    String result = messageFormat.format(args);
    

    The result is:

    insert into 000 values ( '111', '222', '333', 444 )
    

    Is this what you need?

提交回复
热议问题