writeUtf8

common
abstract fun writeUtf8(string: String): BufferedSink

Encodes string in UTF-8 and writes it to this sink.

Buffer buffer = new Buffer();
buffer.writeUtf8("Uh uh uh!");
buffer.writeByte(' ');
buffer.writeUtf8("You didn't say the magic word!");

assertEquals("Uh uh uh! You didn't say the magic word!", buffer.readUtf8());
abstract fun writeUtf8(string: String): BufferedSink
abstract fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): BufferedSink
common
abstract fun writeUtf8(string: String, beginIndex: Int, endIndex: Int): BufferedSink

Encodes the characters at beginIndex up to endIndex from string in UTF-8 and writes it to this sink.

Buffer buffer = new Buffer();
buffer.writeUtf8("I'm a hacker!\n", 6, 12);
buffer.writeByte(' ');
buffer.writeUtf8("That's what I said: you're a nerd.\n", 29, 33);
buffer.writeByte(' ');
buffer.writeUtf8("I prefer to be called a hacker!\n", 24, 31);

assertEquals("hacker nerd hacker!", buffer.readUtf8());