Type Function Library io.* Return value String, Number, or
Revision Current Public Release (2017.3184) Keywords io, read, file See also io.open() io.input()
Reads the file set by io.input(), according to the given formats which specify what to read. For each format, the function returns a string or a number with the characters read, or
nil if it cannot read data with the specified format. When called without formats, it uses a default format that reads the entire next line (
If you are reading data from a file,
file:read() should be used instead of
io.read( [fmt1] [, fmt2] [, ...] )
"*l"— Reads the next line (skipping the end of line), returning
nilon end of file (EOF). This is the default format.
"*n"— Reads a number; this is the only format that returns a number instead of a string.
"*a"— Reads the whole file, starting at the current position. On end of file, it returns the empty string.
nilon end of file. If this number is
0, it reads nothing and returns an empty string, or
nilon end of file.