Skip to content

karmakrafts/kMMIO

Repository files navigation

kMMIO

Lightweight memory mapped IO for Kotlin Multiplatform on JVM, Android and native.
If you need random access on big files, this is the library you're looking for!

This library also comes with kotlinx.io integration out of the box.

How to use it

First, add the official Maven Central repository to your settings.gradle.kts:

dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}

Then add a dependency on the library in your buildscript:

kotlin {
    sourceSets {
        commonMain {
            dependencies {
                implementation("dev.karmakrafts.kmmio:kmmio-core:<version>")
            }
        }
    }
}

Code example

fun main() {
    VirtualMemory(4096, path).use {
        it.source() // Consume data through a kotlinx.io.Source
        it.sink() // Produce data through a kotlinx.io.Sink
    }
}