Skip to content

okio / okio / BufferedSource / readInt

readInt

(js, jvm, native) abstract fun readInt():Int

Removes four bytes from this source and returns a big-endian int.

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

assertEquals(2147483647, buffer.readInt());
assertEquals(4, buffer.size());

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