Expand description
The input and output library.
I/O operations come in two styles. The simple style uses implicit
default files: io.read and io.write operate on
the current input and output files, set with input and output.
The complete style uses explicit file handles
returned by open, with the operations available as methods:
local f = assert(io.open("notes.txt", "r"))
for line in f:lines() do
print(line)
end
f:close()The library also provides three predefined handles: stdin,
stdout and stderr.
Structs§
- file
- A handle to an open file.
Statics§
- stderr
- The standard error file handle.
- stdin
- The standard input file handle.
- stdout
- The standard output file handle.
Functions§
- close
- Closes a file, or the default output file.
- flush
- Flushes the default output file.
- input
- Sets or gets the default input file.
- lines
- Iterates over the lines of a named file.
- open
- Opens a file.
- output
- Sets or gets the default output file.
- popen
- Starts a program and connects to it with a pipe.
- read
- Reads from the default input file.
- tmpfile
- Returns a handle for a temporary file.
- type
- Checks whether a value is a file handle.
- write
- Writes to the default output file.