code: public static String replace(String str, String search, String replace) {
          if (str == null || search == null || replace == null) {
              return str;
          }
          StringBuilder sb = new StringBuilder();
          int searchLen = search.length();
          int stringLen = str.length();
          int oldIndex = 0;
          int index;
          while ((index = str.indexOf(search, oldIndex)) >= 0) {
              sb.append(str, oldIndex, index);
              sb.append(replace);
              oldIndex = index + searchLen;
          }
          if (oldIndex < stringLen) {
              sb.append(str, oldIndex, stringLen);
          }
          return sb.toString();
      }
docs: Replace all occurrences of a substring within a string with another string.
  
  @param str {@code String} to examine
  @param search {@code String} to replace
  @param replace {@code String} to insert
  @return a {@code String} with the replacements