
ZIP input/output streams with Java-compatible byte-array streams, DEFLATE via zlib, adapters for common I/O libraries, and comprehensive ZipEntry metadata plus streaming APIs.
Kotlin Multiplatform ZIP library for JVM and iOS targets.
Provides ByteArrayInputStream, ByteArrayOutputStream, ZipInputStream, and ZipOutputStream with a common API across platforms. On JVM, the implementations delegate to java.io and java.util.zip. On iOS/Native, they are pure Kotlin implementations using platform.zlib for DEFLATE compression and decompression.
| Artifact | Description |
|---|---|
no.synth:kmp-zip |
Core I/O and ZIP streams |
no.synth:kmp-zip-kotlinx |
kotlinx-io Source/Sink adapters for the core streams |
no.synth:kmp-zip-okio |
OkIO BufferedSource/BufferedSink adapters for the core streams |
Published on Maven Central. No special repository configuration needed.
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("no.synth:kmp-zip:0.7.2")
// Optional: kotlinx-io adapters
implementation("no.synth:kmp-zip-kotlinx:0.7.2")
// Optional: OkIO adapters
implementation("no.synth:kmp-zip-okio:0.7.2")
}
}
}
}| Type | Description |
|---|---|
InputStream |
Abstract class — read(), read(ByteArray, off, len), available(), skip(), close(), etc. |
OutputStream |
Abstract class — write(Int), write(ByteArray, off, len), flush(), close()
|
ByteArrayInputStream |
Reads from a ByteArray. Full Java-compatible API. |
ByteArrayOutputStream |
Auto-growing buffer with toByteArray(), size(), reset(), writeTo()
|
InputStream.readBytes() |
Extension that reads all remaining bytes |
| Type | Description |
|---|---|
ZipInputStream(InputStream) |
Reads ZIP entries — nextEntry, closeEntry(), read(), readBytes()
|
ZipInputStream(ByteArray) |
Convenience factory |
ZipOutputStream(OutputStream) |
Writes ZIP entries — putNextEntry(), closeEntry(), write(), finish(), setMethod(), setLevel()
|
ZipEntry |
Entry metadata — name, size, compressedSize, crc, method, isDirectory, time, comment, extra
|
ZipConstants |
STORED = 0, DEFLATED = 8
|
| Type | Description |
|---|---|
SourceInputStream(Source) |
Wraps a kotlinx-io Source as an InputStream
|
SinkOutputStream(Sink) |
Wraps a kotlinx-io Sink as an OutputStream
|
Source.asInputStream() |
Extension shorthand |
Sink.asOutputStream() |
Extension shorthand |
ZipInputStream(Source) |
Factory — creates a ZipInputStream from a Source
|
ZipOutputStream(Sink) |
Factory — creates a ZipOutputStream from a Sink
|
| Type | Description |
|---|---|
SourceInputStream(BufferedSource) |
Wraps an OkIO BufferedSource as an InputStream
|
SinkOutputStream(BufferedSink) |
Wraps an OkIO BufferedSink as an OutputStream
|
BufferedSource.asInputStream() |
Extension shorthand |
BufferedSink.asOutputStream() |
Extension shorthand |
ZipInputStream(BufferedSource) |
Factory — creates a ZipInputStream from a BufferedSource
|
ZipOutputStream(BufferedSink) |
Factory — creates a ZipOutputStream from a BufferedSink
|
ZipInputStream(zipBytes).use { zis ->
while (true) {
val entry = zis.nextEntry ?: break
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}
}val buf = ByteArrayOutputStream()
ZipOutputStream(buf).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello, world!".encodeToByteArray())
zos.closeEntry()
}
val zipBytes = buf.toByteArray()import kotlinx.io.Buffer
import no.synth.kmpzip.kotlinx.ZipInputStream
import no.synth.kmpzip.kotlinx.ZipOutputStream
val buffer = Buffer()
// Write
ZipOutputStream(buffer).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello from kotlinx-io!".encodeToByteArray())
zos.closeEntry()
}
// Read
ZipInputStream(buffer).use { zis ->
val entry = zis.nextEntry ?: error("Expected entry")
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}import okio.Buffer
import no.synth.kmpzip.okio.ZipInputStream
import no.synth.kmpzip.okio.ZipOutputStream
val buffer = Buffer()
// Write
ZipOutputStream(buffer).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello from OkIO!".encodeToByteArray())
zos.closeEntry()
}
// Read
ZipInputStream(buffer).use { zis ->
val entry = zis.nextEntry ?: error("Expected entry")
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}Requires JDK 21 and Xcode (for iOS targets).
./gradlew build # Full build
./gradlew jvmTest # JVM tests
./gradlew iosSimulatorArm64Test # iOS simulator testsTagging a release triggers the GitHub Actions workflow to publish to Maven Central:
git tag v0.7.2
git push origin v0.7.2Kotlin Multiplatform ZIP library for JVM and iOS targets.
Provides ByteArrayInputStream, ByteArrayOutputStream, ZipInputStream, and ZipOutputStream with a common API across platforms. On JVM, the implementations delegate to java.io and java.util.zip. On iOS/Native, they are pure Kotlin implementations using platform.zlib for DEFLATE compression and decompression.
| Artifact | Description |
|---|---|
no.synth:kmp-zip |
Core I/O and ZIP streams |
no.synth:kmp-zip-kotlinx |
kotlinx-io Source/Sink adapters for the core streams |
no.synth:kmp-zip-okio |
OkIO BufferedSource/BufferedSink adapters for the core streams |
Published on Maven Central. No special repository configuration needed.
kotlin {
sourceSets {
commonMain {
dependencies {
implementation("no.synth:kmp-zip:0.7.2")
// Optional: kotlinx-io adapters
implementation("no.synth:kmp-zip-kotlinx:0.7.2")
// Optional: OkIO adapters
implementation("no.synth:kmp-zip-okio:0.7.2")
}
}
}
}| Type | Description |
|---|---|
InputStream |
Abstract class — read(), read(ByteArray, off, len), available(), skip(), close(), etc. |
OutputStream |
Abstract class — write(Int), write(ByteArray, off, len), flush(), close()
|
ByteArrayInputStream |
Reads from a ByteArray. Full Java-compatible API. |
ByteArrayOutputStream |
Auto-growing buffer with toByteArray(), size(), reset(), writeTo()
|
InputStream.readBytes() |
Extension that reads all remaining bytes |
| Type | Description |
|---|---|
ZipInputStream(InputStream) |
Reads ZIP entries — nextEntry, closeEntry(), read(), readBytes()
|
ZipInputStream(ByteArray) |
Convenience factory |
ZipOutputStream(OutputStream) |
Writes ZIP entries — putNextEntry(), closeEntry(), write(), finish(), setMethod(), setLevel()
|
ZipEntry |
Entry metadata — name, size, compressedSize, crc, method, isDirectory, time, comment, extra
|
ZipConstants |
STORED = 0, DEFLATED = 8
|
| Type | Description |
|---|---|
SourceInputStream(Source) |
Wraps a kotlinx-io Source as an InputStream
|
SinkOutputStream(Sink) |
Wraps a kotlinx-io Sink as an OutputStream
|
Source.asInputStream() |
Extension shorthand |
Sink.asOutputStream() |
Extension shorthand |
ZipInputStream(Source) |
Factory — creates a ZipInputStream from a Source
|
ZipOutputStream(Sink) |
Factory — creates a ZipOutputStream from a Sink
|
| Type | Description |
|---|---|
SourceInputStream(BufferedSource) |
Wraps an OkIO BufferedSource as an InputStream
|
SinkOutputStream(BufferedSink) |
Wraps an OkIO BufferedSink as an OutputStream
|
BufferedSource.asInputStream() |
Extension shorthand |
BufferedSink.asOutputStream() |
Extension shorthand |
ZipInputStream(BufferedSource) |
Factory — creates a ZipInputStream from a BufferedSource
|
ZipOutputStream(BufferedSink) |
Factory — creates a ZipOutputStream from a BufferedSink
|
ZipInputStream(zipBytes).use { zis ->
while (true) {
val entry = zis.nextEntry ?: break
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}
}val buf = ByteArrayOutputStream()
ZipOutputStream(buf).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello, world!".encodeToByteArray())
zos.closeEntry()
}
val zipBytes = buf.toByteArray()import kotlinx.io.Buffer
import no.synth.kmpzip.kotlinx.ZipInputStream
import no.synth.kmpzip.kotlinx.ZipOutputStream
val buffer = Buffer()
// Write
ZipOutputStream(buffer).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello from kotlinx-io!".encodeToByteArray())
zos.closeEntry()
}
// Read
ZipInputStream(buffer).use { zis ->
val entry = zis.nextEntry ?: error("Expected entry")
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}import okio.Buffer
import no.synth.kmpzip.okio.ZipInputStream
import no.synth.kmpzip.okio.ZipOutputStream
val buffer = Buffer()
// Write
ZipOutputStream(buffer).use { zos ->
zos.putNextEntry(ZipEntry("hello.txt"))
zos.write("Hello from OkIO!".encodeToByteArray())
zos.closeEntry()
}
// Read
ZipInputStream(buffer).use { zis ->
val entry = zis.nextEntry ?: error("Expected entry")
println("${entry.name}: ${zis.readBytes().decodeToString()}")
}Requires JDK 21 and Xcode (for iOS targets).
./gradlew build # Full build
./gradlew jvmTest # JVM tests
./gradlew iosSimulatorArm64Test # iOS simulator testsTagging a release triggers the GitHub Actions workflow to publish to Maven Central:
git tag v0.7.2
git push origin v0.7.2