Lua io functions

Lua io functions

These are the functions in the "io" table.

Implicit operations (eg. io.read, io.write) use the standard file descriptors io.stdin, io.stdout, and io.stderr.

You can operate on other files by getting a "file descriptor" from io.open, io.input, or io.output, and using that.

Note the syntactical difference, that you follow a file descriptor by a colon, eg. f:close ()

Also see the description for the "os" table for operating system functions that do things like remove and rename files.


The operations whose name start with "f:" (such as f:read) depend on having an open file handle returned from io.open, io.input, or io.output.

Note the colon after the f, as this indicates that the file handle (userdata from the open) is to be supplied as the first argument to the function.

Lua functions

Topics