使用
StringSubstitutorApache的共享文本。
https://commons.apache.org/proper/commons-
text/
它将为您(及其开源…)
Map<String, String> valuesMap = new HashMap<String, String>(); valuesMap.put("animal", "quick brown fox"); valuesMap.put("target", "lazy dog"); String templateString = "The ${animal} jumped over the ${target}."; StringSubstitutor sub = new StringSubstitutor(valuesMap); String resolvedString = sub.replace(templateString);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)