FileTools[Text]

 read all lines from a file

Parameters

 file - file descriptor or filename

Description

 • The ReadFile(file) command reads a string containing all the characters in the file.  For files previously opened, the result string contains all the characters from the current file position to the end of file. The characters are returned as a string.
 • If the file is not open prior to calling ReadFile then it will be closed before returning.  If the file was already open it will not be closed.

Examples

 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteLine}\right]\left("testfile","This is a test"\right)$
 ${15}$ (1)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{WriteLine}\right]\left("testfile","This is also a test"\right)$
 ${20}$ (2)
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{Close}\right]\left("testfile"\right)$
 > $\mathrm{FileTools}\left[\mathrm{Text}\right]\left[\mathrm{ReadFile}\right]\left("testfile"\right)$
 ${"This is a test This is also a test"}$ (3)
 > $\mathrm{FileTools}\left[\mathrm{Remove}\right]\left("testfile"\right)$