一个简单点的case
package com.zh.tool; import java.text.MessageFormat; public class test { public static void main(String[] args) { String paraString = "xxxxx{0}xxxxx{1}xxxxxxxx{2}xxxxxx"; System.out.println(MessageFormat.format(paraString.toString(), "para1", "para2", "para3")); } }
结果:
xxxxxpara1xxxxxpara2xxxxxxxxpara3xxxxxx