File.flush() (Method)

Purges the output buffer to the file after some writing.

Availability:

JavaScript - 1.1
Netscape Enterprise Server - 2.0
JavaScript syntax:NESmyFile.flush()

File writing tends to involve a certain amount of buffering by the file manager in the environment in which you are accessing the files. This is necessary to improve performance and throughput. The data is only physically transferred to the file when a buffer full of data is ready or when the file buffer is closed. This can mean that a JavaScript error can leave the file incomplete if it fails in a way that prevents the file from being closed properly. A run-time error would normally not write any pending data out to a file.

The flush() method allows you to force the file contents to be updated so that the file is complete and there are no pending contents yet to be written. You might force a flush() at the end of a record for example.

A flush() method may be called for much more frequently if you are using fixed length records and manually maintaining an index structure at the front of the file.

See also:File.write(), File.writeByte(), File.writeln(), response.flush()