readShort

abstract fun readShort(): Short(source)

Removes two bytes from this source and returns a short integer composed of it according to the big-endian order.

Throws

when there are not enough data to read a short value.

when the source is closed.

Samples

import kotlinx.io.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   val buffer = Buffer()
buffer.write(byteArrayOf(1, 2, 3, 4))

assertEquals(0x0102, buffer.readShort())
assertEquals(2, buffer.size) 
   //sampleEnd
}