All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.xebia.functional.xef.loaders.TextLoader.kt Maven / Gradle / Ivy

The newest version!
package com.xebia.functional.xef.loaders

import com.xebia.functional.xef.io.DEFAULT
import okio.FileSystem
import okio.Path

/** Creates a TextLoader based on a Path */
suspend fun TextLoader(
  filePath: Path,
  fileSystem: FileSystem = FileSystem.DEFAULT
): BaseLoader = object : BaseLoader {

  override suspend fun load(): List =
    buildList {
      fileSystem.read(filePath) {
        while (true) {
          val line = readUtf8Line() ?: break
          add(line)
        }
      }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy