Created
August 25, 2011 08:28
-
-
Save xdu/1170229 to your computer and use it in GitHub Desktop.
java string variable replacement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map valuesMap = HashMap(); | |
valuesMap.put("animal", "quick brown fox"); | |
valuesMap.put("target", "lazy dog"); | |
String templateString = "The ${animal} jumped over the ${target}."; | |
StrSubstitutor sub = new StrSubstitutor(valuesMap); | |
String resolvedString = sub.replace(templateString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment