From 786dcfbe536fec2972adaab505d2bb630fe8fd8e Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 3 Mar 2024 16:38:43 +0700 Subject: [PATCH] writeByteArray with offset and length --- gradle.properties | 2 +- .../kotlin/ru/dbotthepony/kommons/io/OutputStreamUtils.kt | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c980a9f..e892bb1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ kotlin.code.style=official specifyKotlinAsDependency=false projectGroup=ru.dbotthepony.kommons -projectVersion=2.9.16 +projectVersion=2.9.17 guavaDepVersion=33.0.0 gsonDepVersion=2.8.9 diff --git a/src/main/kotlin/ru/dbotthepony/kommons/io/OutputStreamUtils.kt b/src/main/kotlin/ru/dbotthepony/kommons/io/OutputStreamUtils.kt index 5b4e5b5..cd07670 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/io/OutputStreamUtils.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/io/OutputStreamUtils.kt @@ -316,6 +316,12 @@ fun OutputStream.writeByteArray(value: ByteArray) { write(value) } +fun OutputStream.writeByteArray(value: ByteArray, offset: Int, length: Int) { + Objects.checkFromIndexSize(offset, value.size, length) + writeVarInt(length) + write(value, offset, length) +} + fun OutputStream.writeByteKey(key: ByteKey) { key.write(this) }