FileInputStream
classin packageklyn.io
public class FileInputStream implements InputStream
FileInputStream
All Implemented Interfaces: InputStream

File-backed binary input stream.

import klyn.io

try stream = FilePath("payload.bin").openInputStream():
    header = stream.readBytes(8)
    print(header.size)
Constructors
Modifier and Type Member Description
public FileInputStream
FileInputStream(notnull path as String)
Opens a regular file for buffered binary reading.
Methods
Modifier and Type Member Description
public close
close() as Void throws IOException
Performs a text or binary I/O operation.
public read
read() as String throws IOException
Reads the remaining file contents as strict UTF-8, from the current byte position to end-of-file.
public readBytes
readBytes(length as Long) as Array<Byte> throws IOException
Performs a text or binary I/O operation.
public readInto
readInto(notnull buffer as Byte[], offset as Long = 0l, length as Long = -1l) as Long
Reads into an existing byte buffer without reopening the file or allocating another buffer.
public seek
seek(offset as Long) as Void
Positions the open file at an absolute byte offset, including after EOF.
Inherited Methods
methodInherited Methods from AutoClosable: close