Skip to content

okio / okio / BufferedSource / readShort

readShort

(js, jvm, native) abstract fun readShort():Short

Removes two bytes from this source and returns a big-endian short.

Buffer buffer = new Buffer()
    .writeByte(0x7f)
    .writeByte(0xff)
    .writeByte(0x00)
    .writeByte(0x0f);
assertEquals(4, buffer.size());

assertEquals(32767, buffer.readShort());
assertEquals(2, buffer.size());

assertEquals(15, buffer.readShort());
assertEquals(0, buffer.size());