public static String change(final String string, final String fromString, final String toString) {
    //// Preconditons
    if (string == null)
      throw new InvalidParameterException("string cannot be null");
    if (fromString == null)
      throw new InvalidParameterException("fromString cannot be null");
    if (toString == null)
      throw new InvalidParameterException("toString cannot be null");
    
    final int string_length = string.length();
    final int fromString_length = fromString.length();
    if (string_length == 0 || fromString_length == 0)
      return string;
    final StringBuffer stringBuffer = new StringBuffer(string_length * 2);
    int fromIndex = 0;
    int index = -1;
    while (true) {
      index = string.indexOf(fromString, fromIndex);
      if (index == -1) {
        stringBuffer.append(string.substring(fromIndex));
        break;
      }
      else {
        stringBuffer.append(string.substring(fromIndex, index));
        stringBuffer.append(toString);
        fromIndex = index + fromString_length;
        index = -1;
        if (fromIndex == string_length)
          break;
      }
    }
    return stringBuffer.toString();
  }