FileHandle
Jump to navigation
Jump to search
In Mini Micro and command-line MiniScript, the FileHandle
class is a small class that represents a file that has been opened for reading, writing, or updating via file.open
.
It provides the following methods:
Method | Purpose |
---|---|
isOpen | true if the file is still open; false after close has been called
|
close | close the file, flushing any changes to disk |
position | current read/write position, in bytes from the beginning of the file |
atEnd | true when the current read/write position is at the end of the file |
write s | write a string to the file (in UTF-8 format) |
writeLine s | write a string to the file (in UTF-8 format), followed by a line break |
read | return the rest of the file, as a string (assumes UTF-8 format) |
readLine | return text from the current position to the next line break (assumes UTF-8) |
Note that the write
, writeLine
, read
, and readLine
functions all advance the file position.