Type Function Library io.* Return value Object Revision Release 2022.3683 Keywords io, output, file See also io.input() io.flush() io.write()
Sets the standard output file. When called with a file name, it opens the named file in text mode and sets its handle as the default output file. When called with a file handle, it simply sets this file handle as the default output file. When called without parameters, it returns the current default output file.
The default output is stdout
which is the Corona Simulator Console. This is similar behavior to io.input() but operates over the default output file.
This function returns a file handle of the just-opened file or the handle to the current input file handle.
local tmp = io.output() -- Save current file handle local path = system.pathForFile( "newFile.txt", system.DocumentsDirectory ) io.output( path ) -- Open new file in text mode io.write( "My real data" ) -- Write the file io.output():close() -- Close the file io.output( tmp ) -- Restore the previous file