@Throws(IOException::class) fun readRawBytes(size: Int): ByteArray? { if (size < 0) { throw InvalidProtocolBufferNanoException.negativeSize() } if (bufferPos + size > currentLimit) { skipRawBytes(currentLimit - bufferPos) throw InvalidProtocolBufferNanoException.truncatedMessage() } return if (size <= bufferSize - bufferPos) { val bytes = ByteArray(size) System.arraycopy(buffer, bufferPos, bytes, 0, size) bufferPos += size bytes } else { throw InvalidProtocolBufferNanoException.truncatedMessage() } }
Read a fixed size of bytes from the input .