open

Warning: This section describes the File component of the SpiderMonkey JavaScript interpreter. File is non-standard, not generally compiled into distributions, is a potential source of huge security holes, and not well tested.

Summary

Opens the file, specifying file mode and type.

Syntax

open(mode, type)

Parameters

mode 
A comma-delimited list describing the method to use to open the file, described in detail here.
type 
A string describing the type of file being opened.

Description

This method opens the file, preparing its resources for use by subsequent methods to examine or modify the file. Certain methods of File, such as read and write should not be used when the file is not open. Other methods, such as remove may not be used when the file is open.

Valid file types are text, binary and unicode. Text indicates ASCII text without NUL characters. Binary indicates UTF-8 files. Unicode indicates UCS-2 files. For all file types, carriage returns and linefeeds are treated in a platform-agnostic way.

Examples

Example: Using open

In the following example, myFile is a File object:

myFile.open("read", "text");

See Also

Document Tags and Contributors

 Contributors to this page: fscholz, Jorend, Wesgarland
 Last updated by: fscholz,