Java String replace not working [duplicate]

String is immutable, which means that the html reference doesn’t change, rather the replace method returns a new String object that you have to assign.

html = html.replace(delimiter + entry.getKey()+ delimiter, entry.getValue());

Leave a Comment