klyn.io.FileReader.readPrefix
method
public static readPrefix(filename as String, maxBytes as Int) as String throws IOException:
Description

Reads at most the first maxBytes bytes from a text file.

This helper is intended for bounded previews and tooling. It avoids loading large files entirely before truncation.

Parameters
  • filename File to read from.
  • maxBytes Maximum number of bytes to read.
Returns

Prefix text, trimmed to a valid UTF-8 boundary when possible.

Throws
  • IOException if the resource is closed, inaccessible, not a valid file, or the underlying I/O operation fails.