我正在传递由 {} 填充符和文本组合而成的文本。我正在尝试用一些值填充 {} 并尝试使用 MessageFormat。
String sss = "{0}SomeText{1}\'.{2}SomeText{2}SomeText{0}{0}SomeText{2}{0}SomeText{0}{1}SomeText{0}{2}{0}{0}{1}{0}{2}{0}{0}{2}{0}{0}{1}{0}{2}{0}";
Object[] testArgs = {"nits1", "Nits2","nits#"};
System.out.println(MessageFormat.format(sss,testArgs));
输出
nits1SomeTextNits2.{2}SomeText{2}SomeText{0}{0}SomeText{2}{0}SomeText{0}{1}SomeText{0}{2}{0}{0}{1}{0}{2}{0}{0}{2}{0}{0}{1}{0}{2}{0}