An open API service indexing awesome lists of open source software.

https://github.com/fleeksoft/fleeksoft-io

A lightweight Kotlin Multiplatform port of JDK IO classes (Reader, InputStream, BufferedReader, etc.), with support for character encoding via Charset.
https://github.com/fleeksoft/fleeksoft-io

jdk kotlin kotlin-io kotlin-multiplatform

Last synced: 27 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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](https://img.shields.io/badge/Kotlin-2.1.20-blue.svg?style=flat&logo=kotlin)](https://kotlinlang.org)
![License](https://img.shields.io/badge/license-Apache--2.0-blue)
[![Maven Central](https://img.shields.io/maven-central/v/com.fleeksoft.io/io.svg)](https://central.sonatype.com/artifact/com.fleeksoft.io/io)
---
## 🌐 Supported Platforms
![badge-jvm](http://img.shields.io/badge/platform-jvm-DB413D.svg?style=flat)
![badge-android](http://img.shields.io/badge/platform-android-6EDB8D.svg?style=flat)
![badge-ios](http://img.shields.io/badge/platform-ios-CDCDCD.svg?style=flat)
![badge-mac](http://img.shields.io/badge/platform-macos-111111.svg?style=flat)
![badge-tvos](http://img.shields.io/badge/platform-tvos-808080.svg?style=flat)
![badge-tvos](http://img.shields.io/badge/platform-watchos-808080.svg?style=flat)
![badge-linux](http://img.shields.io/badge/platform-linux-2D3F6C.svg?style=flat)
![badge-windows](http://img.shields.io/badge/platform-windows-4D76CD.svg?style=flat)
![badge-js](https://img.shields.io/badge/platform-js-F8DB5D.svg?style=flat)
![badge-wasm](https://img.shields.io/badge/platform-wasm-F8DB5D.svg?style=flat)

---

## ✨ 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](CharsetsReadme.md)
- **Extension Functions**
```kotlin
"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:`
- Extended: `com.fleeksoft.charset:charset-ext:`

➑️ [More info](CharsetsReadme.md)

---

## πŸ›  Installation

Add dependencies in your `build.gradle.kts`:

```kotlin
commonMain.dependencies {
implementation("com.fleeksoft.io:io-core:")
implementation("com.fleeksoft.io:io:")

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

Find the latest version here:
[![Maven Central](https://img.shields.io/maven-central/v/com.fleeksoft.io/io.svg)](https://central.sonatype.com/artifact/com.fleeksoft.io/io)
---

## πŸš€ Usage Example

```kotlin
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](LICENSE.md) for full details.