1
String[] greetings = {"Hello1", "Hello2", "Hello3"};  
String otherString = "green";
Map<String, String[]> valuesMap = new HashMap<String, String[]>();
valuesMap.put("greeting", greetings);
valuesMap.put("color", otherString );

String templateString = "Its ${color} around. ${greeting} StrSubstitutor APIs.";
StrSubstitutor sub = new StrSubstitutor(valuesMap);
String resolvedString = sub.replace(templateString);

我正在寻找类似于以下内容的输出:

Its green around. Hello1 StrSubstitutor APIs.
or Hello2 StrSubstitutor APIs
or Hello3 StrSubstitutor APIs.

任何建议都会有所帮助。

4

0 回答 0