public class Files
Lightweight full-file I/O helpers.
Files is intended for simple whole-file operations where a stream object would only add lifecycle overhead. Use FileInputStream, FileOutputStream, FileReader or FileWriter when incremental processing is required.
import klyn.io
data as Byte[] = Byte[3]
data[0] = Byte(65)
data[1] = Byte(66)
data[2] = Byte(67)
Files.writeBytes("payload.bin", data)| Modifier and Type | Member | Description |
|---|---|---|
| public static | readBytesInto | Reads bytes from a file directly into an existing byte buffer without allocating a stream object or an intermediate byte array. |
| public static | requireNoSymlinksrequireNoSymlinks(path as Path) as Void |
Refuses symlinks in a path or any ancestor, including dangling links. |
| public static | searchTextsearchText(notnull path as Path, notnull pattern as String, options as SearchOptions = null) as ArrayList<SearchMatch> |
Collects text occurrences in one file or directory using Path's engine. |
| public static | searchTextsearchText(notnull path as Path, notnull pattern as String, options as SearchOptions, notnull consumer as (SearchMatch) -> Boolean) as ULong |
Streams results through Path's engine. |
| public static native | writeBytes | Writes bytes to a file, replacing existing content. |
| public static native | writeBytesWithPrefix | Writes a text prefix followed by bytes to a file, replacing existing content. |
| public static | writeTextAtomic | Publishes UTF-8 text by replacing a file atomically, without a partially written destination. |