FileOutputStream
classin packageklyn.io
public class FileOutputStream implements OutputStream
FileOutputStream
All Implemented Interfaces: OutputStream

File-backed binary output stream.

Opening the stream truncates the target file unless append is requested. One buffered native file handle remains open until close; successive writes do not reopen the path.

import klyn.io

try stream = FilePath("payload.bin").openOutputStream():
    stream.write("OK")
Constructors
Modifier and Type Member Description
public FileOutputStream
FileOutputStream(notnull path as Path, append as Boolean = false)
Opens a binary file addressed by a Path, truncating by default.
public FileOutputStream
FileOutputStream(notnull path as String, append as Boolean = false)
Opens a binary file, truncating by default and retaining its buffered handle.
Methods
Modifier and Type Member Description
public close
close() as Void throws IOException
Performs a text or binary I/O operation.
public flush
flush() as Void
Flushes buffered bytes to the OS; this is not a durable fsync guarantee.
public seek
seek(offset as Long) as Void
Positions the file at an absolute byte offset; the next write may overwrite.
public write
write(value as String) as Void throws IOException
Performs a text or binary I/O operation.
public writeBytes
writeBytes(notnull value as Byte[], offset as Long, length as Long = -1l) as Void
Writes a byte range directly from a reusable buffer without slicing it.
public writeBytes
writeBytes(value as Array<Byte>) as Void throws IOException
Performs a text or binary I/O operation.
Inherited Methods
methodInherited Methods from AutoClosable: close