Files
classin packageklyn.io
public class Files
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)
Methods
Modifier and Type Member Description
public static readBytesInto
readBytesInto(path as String, notnull buffer as Byte[], offset as Long = 0l, length as Long = -1l) as Long
Reads bytes from a file directly into an existing byte buffer without allocating a stream object or an intermediate byte array.
public static requireNoSymlinks
requireNoSymlinks(path as Path) as Void
Refuses symlinks in a path or any ancestor, including dangling links.
public static searchText
searchText(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 searchText
searchText(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
writeBytes(path as String, content as Byte[]) as Void
Writes bytes to a file, replacing existing content.
public static native writeBytesWithPrefix
writeBytesWithPrefix(path as String, prefix as String, content as Byte[]) as Void
Writes a text prefix followed by bytes to a file, replacing existing content.
public static writeTextAtomic
writeTextAtomic(path as Path, content as String) as Void
Publishes UTF-8 text by replacing a file atomically, without a partially written destination.