writeFromArray

fun writeFromArray(characters: CharArray, startIndex: Int, endIndex: Int)(source)

Encodes all the characters in a specific range of a CharArray and writes them to the sink's underlying destination.

This method does not write the 2-byte "UTF length" that comes before standard Modified UTF-8 strings. That must be written separately if needed.

The "range" is defined as a startIndex and endIndex, which behave the same as the first and second operands of Kotlin's infix until function. Both indexes must be at least 0, and the startIndex cannot be greater than the endIndex, though they can be equal to select 0 characters. startIndex must be less than the array's size and endIndex must be less than or equal to size. If the above conditions are not met, an IllegalArgumentException is thrown.

Parameters

characters

The array of characters to write from.

startIndex

The first and lowest index from which characters will be written.

endIndex

The index after startIndex to stop writing the characters at.

This index is exclusive, meaning the character at this index will not be written, nor will any after it.

Throws

if the mutf8Length of the characters in that range exceeds 65535 (UShort.MAX_VALUE).

if an I/O issue occurs while trying to write any or all of the sequence's encoded bytes.


fun writeFromArray(characters: CharArray, range: IntRange)(source)

An alias for writeFromArray that uses a single range parameter, rather than a separate startIndex and endIndex.

Other than that, the entire contract of writeFromArray applies to this method as well.

See also


fun writeFromArray(characters: CharArray)(source)

Encodes all the characters in a CharSequence and writes them to the sink's underlying destination.

This is an alias for writeFromArray with startIndex = 0 and endIndex = characters.size. The selected indices are guaranteed to be valid, so all IllegalArgumentExceptions and IndexOutOfBoundsExceptions documented at writeFromArray are guaranteed not to occur unless also documented on this function. Other than that, the contract & documentation for writeFromArray applies here as well.

See also

Throws