Returned by the system.file.openRead(filename) or system.file.openWrite(filename) functions.
Properties
length |
The byte length of the file returned as an integer. |
stringMode |
Default is 'ansi' but can also be 'utf8' or 'unicode'. This is set automatically if a preamble is found. |
Methods
close() |
Must be called when you're finished with the file. |
readStringArray() |
Returns an array of strings, each representing a line in a text file. |
writeStringArray(stringarray) |
Writes all of the strings in the string array to the file, putting each string on a new line. |
readByte() |
Returns an integer in the range 0-255 read as the next raw byte in the file. |
writeByte(byte) |
Writes an integer in the range 0-255 to the file as raw data. |
flush() |
Writes any outstanding data from any buffers to the disk. |
Examples
This example shows reading and writing an array of strings to/from a file on disk. (Here it's assumed c:\temp exists)
function onClick()
{
// write directory file list out to text file
var outbuf = system.file.getFiles("c:\\temp\\*.*",false);
var file=system.file.openWrite("c:\\mylist.txt");
file.writeStringArray(outbuf);
file.close();
// read files in from text file
var file=system.file.openRead("c:\\mylist.txt");
var inbuf=file.readStringArray();
file.close();
print("Reading file...");
for(var i=0;i<inbuf.length;i++)
{
print("Read: "+inbuf[i]);
}
}
See Also


