Guest User

Untitled

a guest
May 20th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. inline fun InputStream.readChunk(data: ByteArray, block: (ByteArray, Int) -> Unit) {
  2. var index = 0
  3. do {
  4. read().takeIf { it != -1 }?.let { data[index++] = it.toByte() } ?: break
  5. } while (index < data.size)
  6. block(data, index)
  7. }
Add Comment
Please, Sign In to add comment