public static 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.
This is useful for compact binary formats that start with an ASCII header, such as PPM images.
| Parameter | Description |
|---|---|
path | Target file path. |
prefix | Text prefix written before the bytes. A null value is treated as an empty string. |
content | Bytes to append after the prefix. A null value is treated as an empty byte array. |
import klyn.io
pixels as Byte[] = Byte[3]
pixels[0] = Byte(255)
Files.writeBytesWithPrefix("pixel.ppm", "P6\n1 1\n255\n", pixels)