Skip to content

A lightweight Kotlin Multiplatform port of JDK IO classes (Reader, InputStream, BufferedReader, etc.), with support for character encoding via Charset.

License

Notifications You must be signed in to change notification settings

fleeksoft/fleeksoft-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kotlin Multiplatform IO Library

A Kotlin Multiplatform (KMP) port of Java’s IO classes, bringing familiar IO operations to multiplatform projects—JVM, Android, iOS, macOS, Linux, Windows, Web, and beyond.

Kotlin License Maven Central

🌐 Supported Platforms

badge-jvm badge-android badge-ios badge-mac badge-tvos badge-tvos badge-linux badge-windows badge-js badge-wasm


✨ Features

This library is organized into modular components for flexibility and clarity.

Note Direct file read/write APIs are not included. For file operations, use this library in combination with kotlinx-io or okio, which support stream conversions.


🧱 Core Module (com.fleeksoft.io:io-core)

Core components for buffer and charset management.

  • Buffer: Base container (like java.nio.Buffer)
  • ByteBuffer, CharBuffer
  • CharBufferFactory: Helper utilities to create buffers
  • Closeable, Readable: Interfaces for IO components

📦 IO Module (com.fleeksoft.io:io)

Stream and reader abstractions.

  • Character Streams
    • Reader, BufferedReader, StringReader, CharArrayReader
    • PushbackReader, FilterReader
  • Byte Streams
    • InputStream, ByteArrayInputStream, InputStreamReader
    • OutputStream, ByteArrayOutputStream, BufferedOutputStream, FilterOutputStream
  • Charset Support CharsetsReadme.md
  • Extension Functions
    "Hello".byteInputStream() // return ByteArrayInputStream
    "Hello".reader() // return StringReader
    byteArray.inputStream() // return ByteArrayInputStream
    inputStream.reader() // return InputStreamReader
    inputStream.bufferedReader() // return BufferedReader
    reader.buffered() // return BufferedReader
    reader.buffered().readLines()
    bufferedReader.readString(count)```
    


🌐 URI Module (com.fleeksoft.io:uri)

Multiplatform-safe version of java.net.URI.

  • URI: Parse, resolve, normalize URIs
  • URIFactory: Use this instead of URI.create()

🔌 kotlinx-io Integration (com.fleeksoft.io:kotlinx-io)

Interop for working with kotlinx-io streams:

  • Source.asInputStream(): InputStream
  • RawSource.asInputStream(): InputStream
  • InputStream.asSource(): RawSource

🔌 Okio Integration (com.fleeksoft.io:okio)

Interop for Okio-powered IO:

  • Source.asInputStream(): InputStream
  • InputStream.asSource(): Source

🧬 Charset Modules

Support for standard and extended character sets:

  • Standard: com.fleeksoft.charset:charset:<version>
  • Extended: com.fleeksoft.charset:charset-ext:<version>

➡️ More info


🛠 Installation

Add dependencies in your build.gradle.kts:

commonMain.dependencies {
    implementation("com.fleeksoft.io:io-core:<version>")
    implementation("com.fleeksoft.io:io:<version>")

    // Optional integrations
    implementation("com.fleeksoft.io:kotlinx-io:<version>")
    implementation("com.fleeksoft.io:okio:<version>")
}

Find the latest version here: Maven Central

🚀 Usage Example

val str = "Hello, World!"
val byteArray = ByteArray(10)
val charArray = CharArray(10)

val byteArrayInputStream = str.byteInputStream()
val stringReader = str.reader()

val bufferedReader = stringReader.buffered()
val bufferedReader2 = byteArrayInputStream.bufferedReader()

val byteBuffer = ByteBufferFactory.wrap(byteArray)
val charBuffer = CharBufferFactory.wrap(charArray)

🤝 Contributing

Contributions are welcome! Open an issue or submit a pull request to improve features, fix bugs, or enhance documentation.

📄 License

Licensed under the Apache License 2.0. See LICENSE for full details.

About

A lightweight Kotlin Multiplatform port of JDK IO classes (Reader, InputStream, BufferedReader, etc.), with support for character encoding via Charset.

Topics

Resources

License

Stars

Watchers

Forks

Languages