This can be done in a single line without the use of library. Please check java.text.MessageFormat
class.
Example
String stringWithPlaceHolder = "test String with placeholders {0} {1} {2} {3}";
String formattedStrin = java.text.MessageFormat.format(stringWithPlaceHolder, "place-holder-1", "place-holder-2", "place-holder-3", "place-holder-4");
Output will be
test String with placeholders place-holder-1 place-holder-2 place-holder-3 place-holder-4