klyn.io.Files.writeBytesWithPrefix
method
public static writeBytesWithPrefix(path as String, prefix as String, content as Byte[]) as Void:
Description

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.

Parameters
ParameterDescription
pathTarget file path.
prefixText prefix written before the bytes. A null value is treated as an empty string.
contentBytes to append after the prefix. A null value is treated as an empty byte array.
Throws
  • IOException if the file cannot be opened or written.
Example
import klyn.io

pixels as Byte[] = Byte[3]
pixels[0] = Byte(255)
Files.writeBytesWithPrefix("pixel.ppm", "P6\n1 1\n255\n", pixels)