File.writeln()

NES2+Syntax

							file.writeln(string)

Description

The writeln() method of the File object writes the string passed to the method, followed by a carriage return to the file on which it was invoked. The method returns true if it was successful and false otherwise. You should use the read() or readln() methods to read any string information from other files you want to write. If you need to write binary information, use the writeByte() method.

Example

Listing 8.89 writes the line "Hello, World!" to the summary file opened.

Listing 8.89 Using writeln() to Write a String and Carriage Return to a File
 <SERVER> // Set an instance of a File var mySummary = new File("/data/logs/summary.log"); // Open the log file for writing mySummary.open("w"); ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.