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() |
Prev | Home | Next |
File.exists() | Up | File.getLength() |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |