Dart API Referencedart:coreStringBuffer

StringBuffer abstract class

The StringBuffer class is useful for concatenating strings efficiently. Only on a call to toString are the strings concatenated to a single String.

abstract class StringBuffer {
  /**
   * Creates the string buffer with an initial content.
   */
  factory StringBuffer([Object content = ""]) => new StringBufferImpl(content);

  /**
   * Returns the length of the buffer.
   */
  int get length;

  /**
   * Returns whether the buffer is empty.
   */
  bool isEmpty();

  /**
   * Converts [obj] to a string and adds it to the buffer. Returns [:this:].
   */
  StringBuffer add(Object obj);

  /**
   * Adds the string representation of [charCode] to the buffer.
   * Returns [this].
   */
  StringBuffer addCharCode(int charCode);

  /**
   * Adds all items in [objects] to the buffer. Returns [:this:].
   */
  StringBuffer addAll(Collection objects);

  /**
   * Clears the string buffer. Returns [:this:].
   */
  StringBuffer clear();

  /**
   * Returns the contents of buffer as a concatenated string.
   */
  String toString();
}

Subclasses

StringBufferImpl

Constructors

factory StringBuffer([Object content = ""]) #

Creates the string buffer with an initial content.

factory StringBuffer([Object content = ""]) => new StringBufferImpl(content);

Properties

final int length #

Returns the length of the buffer.

int get length;

Methods

StringBuffer add(Object obj) #

Converts obj to a string and adds it to the buffer. Returns this.

StringBuffer add(Object obj);

StringBuffer addAll(Collection objects) #

Adds all items in objects to the buffer. Returns this.

StringBuffer addAll(Collection objects);

StringBuffer addCharCode(int charCode) #

Adds the string representation of charCode to the buffer. Returns this.

StringBuffer addCharCode(int charCode);

StringBuffer clear() #

Clears the string buffer. Returns this.

StringBuffer clear();

bool isEmpty() #

Returns whether the buffer is empty.

bool isEmpty();

String toString() #

Returns the contents of buffer as a concatenated string.

String toString();