| Availability: |
| |||
| JavaScript syntax: | NES | myFile = File | ||
| NES | myFile = new File(aName) | |||
| Argument list: | aName | A valid file name | ||
| Object methods: | byteToString(), clearError(), close(), eof(), error(), exists(), flush(), getLength(), getPosition(), open(), read(), readByte(), readln(), setPosition(), stringToByte(), write(), writeByte(), writeln() | |||
You can create a new instance of this class with the File() constructor.
Files tend to behave in a somewhat similar way in all languages and implementations. This generally means that they will read and write in 8 bit character sized elements. Beware of this as JavaScript is Unicode based so file contents may not exactly mirror the in-memory representation of a string.
Be careful not to confuse this with the JScript File object. The JScript object may be supported in a Microsoft server but the Netscape Enterprise Server supports an object with a mutually exclusive set of properties and methods and neither kind of File object has any chance of being portable between a Netscape Enterprise Server and a Microsoft server. There are so many other differences between their object models that it is a waste of time trying to write a portable server-side script.
| See also: | Netscape Enterprise Server, unwatch(), watch() |
| Method | JavaScript | JScript | N | IE | Opera | NES | ECMA | DOM | CSS | HTML | Notes |
|---|---|---|---|---|---|---|---|---|---|---|---|
| byteToString() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| clearError() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| close() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| eof() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| error() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| exists() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| flush() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| getLength() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| getPosition() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| open() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| read() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| readByte() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| readln() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| setPosition() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| stringToByte() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| write() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| writeByte() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| writeln() | 1.1 ![]() | ![]() | ![]() | ![]() | ![]() | 2.0 ![]() | ![]() | ![]() | ![]() | ![]() | - |
| Prev | Home | Next |
| File.Type | Up | File() |
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. | ||