I am working with a code where I want fill several string place holders with another strings. This is the example text I have used to test my code.
String myStr = "Media file %s of size %s has been approved"
This is how I fill the place holders. Since I expect to use several place holders I have used java Map<>.
Map<String, String> propMap = new HashMap<String,String>();
propMap.put("file name","20mb");
String newNotification = createNotification(propMap);
I used following method to create the string.
public String createNotification(Map<String, String> properties){
String message = "";
message = String.format(myStr, properties);
return message;
}
How do I replace two of '%s' with "file name" and "20mb"?