NRF SDK 0.9

Reference

Files

Read a bounded UTF-8 file from Kotlin/Native.

Usage context

ModulePackageSDK source
Kotlin/Nativenimbykotlin/src/nimby/Files.kt

Public API for SDK 0.9.0-alpha.2. Each entry provides the Kotlin signature and its contract: what the value means, conditions of use and effects to understand. Choose imports from the module shown above.

Imports on this page
import nimby.readTextFile

Read a file

kotlin
val contenu = nimby.readTextFile("config/options.json")

The path is resolved from the working directory. Reading is limited to 4,194,304 bytes and closes the file even on error. The SDK does not automatically parse JSON or save the file for you.

readTextFile

nimby · fun
fun readTextFile(path: String): String

Reads and closes a local UTF-8 file, up to 4 MiB. An empty file returns an empty string. Opening, size and reading errors throw; this helper does not automatically search the package.