public static 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.
| Parameter | Description |
|---|---|
path | Source file path. |
buffer | Destination byte buffer to fill. |
offset | Non-negative file byte offset where reading begins. |
length | Maximum number of bytes to read; -1 reads up to buffer.size. |
Number of bytes actually read (0 at or past end-of-file).
import klyn.io
scratch as Byte[] = Byte[4096]
count = Files.readBytesInto("README.md", scratch)
print(count)