StringBuilder

class StringBuilder constructor(content: String) : Appendable, CharSequence

A mutable sequence of characters.

String builder can be used to efficiently perform multiple string manipulation operations.

class StringBuilder constructor(content: String) : Appendable, CharSequence

A mutable sequence of characters.

String builder can be used to efficiently perform multiple string manipulation operations.

class StringBuilder constructor(content: String) : CharSequence, Appendable

A mutable sequence of characters.

String builder can be used to efficiently perform multiple string manipulation operations.

typealias StringBuilder = StringBuilder

Constructors

StringBuilder
Link copied to clipboard
fun StringBuilder()

Constructs an empty string builder.

StringBuilder
Link copied to clipboard
fun StringBuilder(capacity: Int)

Constructs an empty string builder with the specified initial capacity.

fun StringBuilder(capacity: Int)

Constructs an empty string builder with the specified initial capacity.

fun StringBuilder(capacity: Int)

Constructs an empty string builder with the specified initial capacity.

StringBuilder
Link copied to clipboard
fun StringBuilder(content: CharSequence)

Constructs a string builder that contains the same characters as the specified content char sequence.

fun StringBuilder(content: CharSequence)

Constructs a string builder that contains the same characters as the specified content char sequence.

fun StringBuilder(content: CharSequence)

Constructs a string builder that contains the same characters as the specified content char sequence.

StringBuilder
Link copied to clipboard
fun StringBuilder(content: String)

Constructs a string builder that contains the same characters as the specified content string.

fun StringBuilder(content: String)
fun StringBuilder(content: String)

Constructs a string builder that contains the same characters as the specified content string.

Functions

append
Link copied to clipboard
fun append(value: Any?): StringBuilder
fun append(value: Any?): StringBuilder
fun append(value: Any?): StringBuilder

Appends the string representation of the specified object value to this string builder and returns this instance.

fun append(value: Boolean): StringBuilder
fun append(value: Boolean): StringBuilder

Appends the string representation of the specified boolean value to this string builder and returns this instance.

Since Kotlin

1.3
Native
fun append(value: Boolean): StringBuilder

Appends the string representation of the specified boolean value to this string builder and returns this instance.

fun append(value: Byte): StringBuilder
fun append(value: Double): StringBuilder
fun append(value: Float): StringBuilder
fun append(value: Int): StringBuilder
fun append(value: Long): StringBuilder
fun append(value: Short): StringBuilder
fun append(value: String): StringBuilder
fun append(value: String): StringBuilder
open override fun append(value: Char): StringBuilder
open override fun append(value: Char): StringBuilder
open override fun append(value: Char): StringBuilder

Appends the specified character value to this Appendable and returns this instance.

fun append(value: CharArray): StringBuilder
fun append(value: CharArray): StringBuilder

Appends characters in the specified character array value to this string builder and returns this instance.

Since Kotlin

1.4
Native
fun append(value: CharArray): StringBuilder

Appends characters in the specified character array value to this string builder and returns this instance.

open override fun append(value: CharSequence?): StringBuilder
open override fun append(value: CharSequence?): StringBuilder
open override fun append(value: CharSequence?): StringBuilder

Appends the specified character sequence value to this Appendable and returns this instance.

fun append(value: String?): StringBuilder
fun append(value: String?): StringBuilder

Appends the specified string value to this string builder and returns this instance.

Since Kotlin

1.3
Native
fun append(value: String?): StringBuilder

Appends the specified string value to this string builder and returns this instance.

open override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder
open override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder
open override fun append(value: CharSequence?, startIndex: Int, endIndex: Int): StringBuilder

Appends a subsequence of the specified character sequence value to this Appendable and returns this instance.

appendRange
Link copied to clipboard
JS
fun appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Appends characters in a subarray of the specified character array value to this string builder and returns this instance.

Since Kotlin

1.4
Native
fun appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Appends characters in a subarray of the specified character array value to this string builder and returns this instance.

Since Kotlin

1.4
JS
fun appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Appends a subsequence of the specified character sequence value to this string builder and returns this instance.

Since Kotlin

1.4
Native
fun appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Appends a subsequence of the specified character sequence value to this string builder and returns this instance.

Since Kotlin

1.4
capacity
Link copied to clipboard
fun capacity(): Int
fun capacity(): Int

Returns the current capacity of this string builder.

Since Kotlin

1.3
Native
fun capacity(): Int

Returns the current capacity of this string builder.

clear
Link copied to clipboard
JS
fun clear(): StringBuilder

Clears the content of this string builder making it empty and returns this instance.

Since Kotlin

1.3
deleteAt
Link copied to clipboard
JS
fun deleteAt(index: Int): StringBuilder

Removes the character at the specified index from this string builder and returns this instance.

Since Kotlin

1.4
Native
fun deleteAt(index: Int): StringBuilder

Removes the character at the specified index from this string builder and returns this instance.

Since Kotlin

1.4
deleteRange
Link copied to clipboard
fun deleteRange(startIndex: Int, endIndex: Int): StringBuilder
fun deleteRange(startIndex: Int, endIndex: Int): StringBuilder

Removes characters in the specified range from this string builder and returns this instance.

Since Kotlin

1.4
ensureCapacity
Link copied to clipboard
fun ensureCapacity(minimumCapacity: Int)
fun ensureCapacity(minimumCapacity: Int)

Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.

Since Kotlin

1.4
Native
fun ensureCapacity(minimumCapacity: Int)

Ensures that the capacity of this string builder is at least equal to the specified minimumCapacity.

get
Link copied to clipboard
Common
open operator override fun get(index: Int): Char
open operator override fun get(index: Int): Char
open operator override fun get(index: Int): Char

Returns the character at the specified index in this character sequence.

indexOf
Link copied to clipboard
fun indexOf(string: String): Int
fun indexOf(string: String): Int
fun indexOf(string: String): Int

Returns the index within this string builder of the first occurrence of the specified string.

Since Kotlin

1.4
fun indexOf(string: String, startIndex: Int): Int
fun indexOf(string: String, startIndex: Int): Int
fun indexOf(string: String, startIndex: Int): Int

Returns the index within this string builder of the first occurrence of the specified string, starting at the specified startIndex.

Since Kotlin

1.4
insert
Link copied to clipboard
fun insert(index: Int, value: Any?): StringBuilder
fun insert(index: Int, value: Any?): StringBuilder

Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: Any?): StringBuilder

Inserts the string representation of the specified object value into this string builder at the specified index and returns this instance.

fun insert(index: Int, value: Boolean): StringBuilder
fun insert(index: Int, value: Boolean): StringBuilder

Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: Boolean): StringBuilder

Inserts the string representation of the specified boolean value into this string builder at the specified index and returns this instance.

fun insert(index: Int, value: Byte): StringBuilder
fun insert(index: Int, value: Double): StringBuilder
fun insert(index: Int, value: Float): StringBuilder
fun insert(index: Int, value: Int): StringBuilder
fun insert(index: Int, value: Long): StringBuilder
fun insert(index: Int, value: Short): StringBuilder
fun insert(index: Int, value: String): StringBuilder
fun insert(index: Int, value: String): StringBuilder
fun insert(index: Int, value: Char): StringBuilder
fun insert(index: Int, value: Char): StringBuilder

Inserts the specified character value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: Char): StringBuilder

Inserts the specified character value into this string builder at the specified index and returns this instance.

fun insert(index: Int, value: CharArray): StringBuilder
fun insert(index: Int, value: CharArray): StringBuilder

Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: CharArray): StringBuilder

Inserts characters in the specified character array value into this string builder at the specified index and returns this instance.

fun insert(index: Int, value: CharSequence?): StringBuilder
fun insert(index: Int, value: CharSequence?): StringBuilder

Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: CharSequence?): StringBuilder

Inserts characters in the specified character sequence value into this string builder at the specified index and returns this instance.

fun insert(index: Int, value: String?): StringBuilder
fun insert(index: Int, value: String?): StringBuilder

Inserts the string value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insert(index: Int, value: String?): StringBuilder

Inserts the string value into this string builder at the specified index and returns this instance.

insertRange
Link copied to clipboard
JS
fun insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
JS
fun insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
Native
fun insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.

Since Kotlin

1.4
lastIndexOf
Link copied to clipboard
fun lastIndexOf(string: String): Int
fun lastIndexOf(string: String): Int
fun lastIndexOf(string: String): Int

Returns the index within this string builder of the last occurrence of the specified string. The last occurrence of empty string "" is considered to be at the index equal to this.length.

Since Kotlin

1.4
fun lastIndexOf(string: String, startIndex: Int): Int
fun lastIndexOf(string: String, startIndex: Int): Int
fun lastIndexOf(string: String, startIndex: Int): Int

Returns the index within this string builder of the last occurrence of the specified string, starting from the specified startIndex toward the beginning.

Since Kotlin

1.4
reverse
Link copied to clipboard
Common
fun reverse(): StringBuilder

Reverses the contents of this string builder and returns this instance.

set
Link copied to clipboard
JS
operator fun set(index: Int, value: Char)

Sets the character at the specified index to the specified value.

Since Kotlin

1.4
Native
operator fun set(index: Int, value: Char)

Sets the character at the specified index to the specified value.

setLength
Link copied to clipboard
fun setLength(newLength: Int)
fun setLength(newLength: Int)

Sets the length of this string builder to the specified newLength.

Since Kotlin

1.4
Native
fun setLength(newLength: Int)

Sets the length of this string builder to the specified newLength.

setRange
Link copied to clipboard
JS
fun setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder

Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.

Since Kotlin

1.4
Native
fun setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder

Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.

Since Kotlin

1.4
subSequence
Link copied to clipboard
Common
open override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
open override fun subSequence(startIndex: Int, endIndex: Int): CharSequence
open override fun subSequence(startIndex: Int, endIndex: Int): CharSequence

Returns a new character sequence that is a subsequence of this character sequence, starting at the specified startIndex and ending right before the specified endIndex.

substring
Link copied to clipboard
Common
fun substring(startIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).

Since Kotlin

1.4
JS
fun substring(startIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).

Since Kotlin

1.4
Native
fun substring(startIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the length (exclusive).

Since Kotlin

1.4
Common
fun substring(startIndex: Int, endIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).

Since Kotlin

1.4
JS
fun substring(startIndex: Int, endIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).

Since Kotlin

1.4
Native
fun substring(startIndex: Int, endIndex: Int): String

Returns a new String that contains characters in this string builder at startIndex (inclusive) and up to the endIndex (exclusive).

toCharArray
Link copied to clipboard
JS
fun toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.4
Native
fun toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)

Copies characters from this string builder into the destination character array.

Since Kotlin

1.4
toString
Link copied to clipboard
open override fun toString(): String
open override fun toString(): String
trimToSize
Link copied to clipboard
Common
fun trimToSize()

Attempts to reduce storage used for this string builder.

Since Kotlin

1.4
Native
fun trimToSize()

Attempts to reduce storage used for this string builder.

Properties

length
Link copied to clipboard
open override val length: Int
open override val length: Int

Returns the length of this character sequence.

open override val length: Int

Returns the length of this character sequence.

Extensions

append
Link copied to clipboard
inline fun StringBuilder.append(obj: Any?): StringBuilder
inline fun StringBuilder.append(it: Boolean): StringBuilder
inline fun StringBuilder.append(it: Byte): StringBuilder
inline fun StringBuilder.append(it: Short): StringBuilder
inline fun StringBuilder.append(it: Int): StringBuilder
inline fun StringBuilder.append(it: Long): StringBuilder
inline fun StringBuilder.append(it: Float): StringBuilder
inline fun StringBuilder.append(it: Double): StringBuilder
inline fun StringBuilder.append(it: String): StringBuilder
inline fun StringBuilder.append(it: CharArray): StringBuilder
Common
fun StringBuilder.append(vararg value: String?): StringBuilder
fun StringBuilder.append(vararg value: Any?): StringBuilder

Appends all arguments to the given StringBuilder.

appendLine
Link copied to clipboard
Common
inline fun StringBuilder.appendLine(): StringBuilder

Appends a line feed character (\n) to this StringBuilder.

inline fun StringBuilder.appendLine(value: CharSequence?): StringBuilder
inline fun StringBuilder.appendLine(value: String?): StringBuilder
inline fun StringBuilder.appendLine(value: Any?): StringBuilder
inline fun StringBuilder.appendLine(value: CharArray): StringBuilder
inline fun StringBuilder.appendLine(value: Char): StringBuilder
inline fun StringBuilder.appendLine(value: Boolean): StringBuilder
inline fun StringBuilder.appendLine(value: StringBuffer?): StringBuilder
inline fun StringBuilder.appendLine(value: StringBuilder?): StringBuilder
inline fun StringBuilder.appendLine(value: Int): StringBuilder
inline fun StringBuilder.appendLine(value: Short): StringBuilder
inline fun StringBuilder.appendLine(value: Byte): StringBuilder
inline fun StringBuilder.appendLine(value: Long): StringBuilder
inline fun StringBuilder.appendLine(value: Float): StringBuilder
inline fun StringBuilder.appendLine(value: Double): StringBuilder
inline fun StringBuilder.appendLine(value: Byte): StringBuilder
inline fun StringBuilder.appendLine(value: Short): StringBuilder
inline fun StringBuilder.appendLine(value: Int): StringBuilder
inline fun StringBuilder.appendLine(value: Long): StringBuilder
inline fun StringBuilder.appendLine(value: Float): StringBuilder
inline fun StringBuilder.appendLine(value: Double): StringBuilder

Appends value to this StringBuilder, followed by a line feed character (\n).

appendln
Link copied to clipboard
fun StringBuilder.appendln(): StringBuilder

Appends a line separator to this StringBuilder.

inline fun StringBuilder.appendln(value: StringBuffer?): StringBuilder
inline fun StringBuilder.appendln(value: CharSequence?): StringBuilder
inline fun StringBuilder.appendln(value: String?): StringBuilder
inline fun StringBuilder.appendln(value: Any?): StringBuilder
inline fun StringBuilder.appendln(value: StringBuilder?): StringBuilder
inline fun StringBuilder.appendln(value: CharArray): StringBuilder
inline fun StringBuilder.appendln(value: Char): StringBuilder
inline fun StringBuilder.appendln(value: Boolean): StringBuilder
inline fun StringBuilder.appendln(value: Int): StringBuilder
inline fun StringBuilder.appendln(value: Short): StringBuilder
inline fun StringBuilder.appendln(value: Byte): StringBuilder
inline fun StringBuilder.appendln(value: Long): StringBuilder
inline fun StringBuilder.appendln(value: Float): StringBuilder
inline fun StringBuilder.appendln(value: Double): StringBuilder

Appends value to this StringBuilder, followed by a line separator.

Native
fun StringBuilder.appendln(it: String): StringBuilder
fun StringBuilder.appendln(it: Boolean): StringBuilder
fun StringBuilder.appendln(it: Byte): StringBuilder
fun StringBuilder.appendln(it: Short): StringBuilder
fun StringBuilder.appendln(it: Int): StringBuilder
fun StringBuilder.appendln(it: Long): StringBuilder
fun StringBuilder.appendln(it: Float): StringBuilder
fun StringBuilder.appendln(it: Double): StringBuilder
fun StringBuilder.appendln(it: Any?): StringBuilder
fun StringBuilder.appendln(): StringBuilder
appendRange
Link copied to clipboard
fun StringBuilder.appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.appendRange(value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Appends characters in a subarray of the specified character array value to this string builder and returns this instance.

fun StringBuilder.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.appendRange(value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Appends a subsequence of the specified character sequence value to this string builder and returns this instance.

clear
Link copied to clipboard
fun StringBuilder.clear(): StringBuilder
inline fun StringBuilder.clear(): StringBuilder

Clears the content of this string builder making it empty and returns this instance.

deleteAt
Link copied to clipboard
fun StringBuilder.deleteAt(index: Int): StringBuilder
inline fun StringBuilder.deleteAt(index: Int): StringBuilder
inline fun StringBuilder.deleteAt(index: Int): StringBuilder

Removes the character at the specified index from this string builder and returns this instance.

deleteCharAt
Link copied to clipboard
Native
inline fun StringBuilder.deleteCharAt(index: Int): StringBuilder

Removes the character at the specified index from this string builder and returns this instance.

deleteRange
Link copied to clipboard
fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.deleteRange(startIndex: Int, endIndex: Int): StringBuilder

Removes characters in the specified range from this string builder and returns this instance.

ensureCapacity
Link copied to clipboard
Native
inline fun StringBuilder.ensureCapacity(capacity: Int)
insert
Link copied to clipboard
Native
inline fun StringBuilder.insert(index: Int, c: Char): StringBuilder
inline fun StringBuilder.insert(index: Int, chars: CharArray): StringBuilder
inline fun StringBuilder.insert(index: Int, csq: CharSequence?): StringBuilder
inline fun StringBuilder.insert(index: Int, string: String): StringBuilder
inline fun StringBuilder.insert(index: Int, csq: CharSequence?, start: Int, end: Int): StringBuilder

Inserts characters in a subsequence of the specified character sequence csq into this string builder at the specified index and returns this instance.

insertRange
Link copied to clipboard
fun StringBuilder.insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.insertRange(index: Int, value: CharArray, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subarray of the specified character array value into this string builder at the specified index and returns this instance.

fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder
inline fun StringBuilder.insertRange(index: Int, value: CharSequence, startIndex: Int, endIndex: Int): StringBuilder

Inserts characters in a subsequence of the specified character sequence value into this string builder at the specified index and returns this instance.

set
Link copied to clipboard
operator fun StringBuilder.set(index: Int, value: Char)
inline operator fun StringBuilder.set(index: Int, value: Char)
inline operator fun StringBuilder.set(index: Int, value: Char)

Sets the character at the specified index to the specified value.

setCharAt
Link copied to clipboard
Native
inline fun StringBuilder.setCharAt(index: Int, value: Char)
setLength
Link copied to clipboard
Native
inline fun StringBuilder.setLength(l: Int)
setRange
Link copied to clipboard
fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder
inline fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder
inline fun StringBuilder.setRange(startIndex: Int, endIndex: Int, value: String): StringBuilder

Replaces characters in the specified range of this string builder with characters in the specified string value and returns this instance.

toCharArray
Link copied to clipboard
fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)
inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)
inline fun StringBuilder.toCharArray(destination: CharArray, destinationOffset: Int = 0, startIndex: Int = 0, endIndex: Int = this.length)

Copies characters from this string builder into the destination character array.