TextWriter

The TextWriter object, returned by the openTextWriter() function, allows to open a text file, write to it and close it.

Methods

The following table describes the methods of the TextWriter object.

Property/method

Description

close()

Close the stream.

newLine()

Creates a new line in the file.

open(filename)

Creates a new writer on a file to write at the beginning of the file.
Parameters:

  • filename: the path of the file to open

open(inFilename, inEncoding, append)

Creates a new writer on a file.
Parameters:

  • inFileName: the path of the file

  • inEncoding: the encoding to be used when writing to the file

  • append: boolean; true if the data will be written at the end of the file

write(c)

Writes a character in the file

write(value)

Writes a string in the file.
Parameters:

  • value: the string value to write