Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

%%classpath add mvn
org.apache.commons commons-text 1.8
Loading...
Loading...
import org.apache.commons.text.StringSubstitutor;
import java.util.Map;
import java.util.HashMap;

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);
System.out.println(resolvedString);
The quick brown fox jumped over the lazy dog.
null
import java.text.MessageFormat;

Object[] params = new Object[]{"hello", "!"};
String msg = MessageFormat.format("{0} world {1}", params);
System.out.println(msg);
hello world !
null

String.format

String msg = String.format("Hello! My name is %s, I'm %s.", "Ben", 32);
System.out.println(msg);
Hello! My name is Ben, I'm 32.
null