writeLine

Syntax

writeLine(handle, line, [windowsLineEnding])

Arguments

The optional Boolean parameter windowsLineEnding is the line ending character. If the parameter is not specified, the line ending character would be:

  • \r\n if handle is a socket

  • \n if handle is a file and the operation system is not Windows

  • \r\n if handle is a file and the operating system is Windows

Details

Write a line to the given handle. The function will automatically append a line delimiter to the string. Thus the string shouldn't end with a line delimiter. If the operation succeeds, it returns 1; otherwise, an IOException will be raised.

Examples

x=`IBM`MSFT`GOOG`YHOO`ORCL
eachRight(writeLine, file("test.txt","w"), x);
// output
[1,1,1,1,1]

fin = file("test.txt")
do{
   x=fin.readLine()
   if(x.isVoid()) break
   print x
}
while(true);

// output
IBM
MSFT
GOOG
YHOO
ORCL