该类可以进行占位符填写
如下
String msg = "啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊{0}{1}{2}{3}{4}{5}{6}{7}{8}哦哦哦哦哦哦哦哦哦哦哦哦";
Object [] array = new Object[]{"A","B","C","D","E","F","G","H","I",};
String value = MessageFormat.format(msg, array);
System.out.println(value); // 输出:啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊ABCDEFGHI哦哦哦哦哦哦哦哦哦哦哦哦
如何让他不解析指定的中括号呢?
将中括号使用单引号引起来
String str=" ‘{‘code:{1},info:{2},message:{3} ‘}‘ ";
这种可以避免过于频繁的操作字符串了