Skip to content

okio / okio / BufferedSink / writeShort

writeShort

(js, jvm, native) abstract fun writeShort(s:Int):BufferedSink

Writes a big-endian short to this sink using two bytes.

Buffer buffer = new Buffer();
buffer.writeShort(32767);
buffer.writeShort(15);

assertEquals(4, buffer.size());
assertEquals((byte) 0x7f, buffer.readByte());
assertEquals((byte) 0xff, buffer.readByte());
assertEquals((byte) 0x00, buffer.readByte());
assertEquals((byte) 0x0f, buffer.readByte());
assertEquals(0, buffer.size());