## File

    Object
       |
       +--File

Deprecated use {link helma.File} instead
Defined in File.js

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Constructor Summary
`File(<String> filepath)` Constructor for File objects, providing read and write access to the file system.

Methods Summary
`Boolean` | `canRead()` Tests whether the application can read the file represented by this File object.
`Boolean` | `canWrite()` Tests whether the file represented by this File object is writable.
`void` | `clearError()` Clears any error message that may otherwise be returned by the error method.
`Boolean` | `close()` Closes the file represented by this File object.
`Boolean` | `eof()` Returns true if the file represented by this File object has been read entirely and the end of file has been reached.
`String` | `error(Object)` Contains the last error that occured, if any.
`Boolean` | `exists()` Tests whether the file or directory represented by this File object exists.
`Boolean` | `flush()` Purges the content of the file represented by this File object.
`String` | `getAbsolutePath()` Returns the absolute pathname string of this file.
`Number` | `getLength()` Returns the length of the file represented by this File object.
`String` | `getName()` Returns the name of the file or directory represented by this File object.
`String` | `getParent()` Returns the pathname string of this File object's parent directory.
`String` | `getPath()` Returns the pathname string of this File object.
`Boolean` | `isAbsolute()` Tests whether this File object's pathname is absolute.
`Boolean` | `isDirectory()` Tests whether the file represented by this File object is a directory.
`Boolean` | `isFile()` Tests whether the file represented by this File object is a normal file.
`Boolean` | `isOpened()` Returns true if the file represented by this File object is currently open.
`Number` | `lastModified()` Returns the time when the file represented by this File object was last modified.
`Object` | `list(<RegExp> pattern)` List of all files within the directory represented by this File object.
`Boolean` | `mkdir()` Creates the directory represented by this File object.
`Boolean` | `open()` Opens the file represented by this File object.
`String` | `readAll()` This methods reads all the lines contained in the file and returns them.
`String` | `readln()` This methods reads characters until an end of line/file is encountered then returns the string for these characters (without any end of line character).
`Boolean` | `remove()` Deletes the file or directory represented by this File object.
`Boolean` | `renameTo(<String> dest)` Renames the file represented by this File object.
`Boolean` | `write(<String> data)` Appends a string to the file represented by this File object.
`Boolean` | `writeln(<String> data)` Appends a string with a platform specific end of line to the file represented by this File object.

Constructor Detail

### File

    File(<String> filepath)

Constructor for File objects, providing read and write access to the file system.
Example:

     var fileOrDir = new File('static/test.txt');

Parameters:

`filepath` - as String

Deprecated use {link helma.File} instead

Method Detail

### canRead

    Boolean canRead()

Tests whether the application can read the file represented by this File object.

Returns:

Boolean true if the file exists and can be read; false otherwise

### canWrite

    Boolean canWrite()

Tests whether the file represented by this File object is writable.

Returns:

Boolean true if the file exists and can be modified; false otherwise.

### clearError

    void clearError()

Clears any error message that may otherwise be returned by the error method.

See:

- error()

### close

    Boolean close()

Closes the file represented by this File object.

Returns:

Boolean

### eof

    Boolean eof()

Returns true if the file represented by this File object has been read entirely and the end of file has been reached.

Returns:

Boolean

### error

    String error(Object)

Contains the last error that occured, if any.

Returns:

String

See:

- clearError()

### exists

    Boolean exists()

Tests whether the file or directory represented by this File object exists.

Returns:

Boolean true if the file or directory exists; false otherwise

### flush

    Boolean flush()

Purges the content of the file represented by this File object.

Returns:

Boolean

### getAbsolutePath

    String getAbsolutePath()

Returns the absolute pathname string of this file.
If this File object's pathname is already absolute, then the pathname string is simply returned as if by the getPath() method. If this abstract pathname is the empty abstract pathname then the pathname string of the current user directory, which is named by the system property user.dir, is returned. Otherwise this pathname is resolved in a system-dependent way. On UNIX systems, a relative pathname is made absolute by resolving it against the current user directory. On Microsoft Windows systems, a relative pathname is made absolute by resolving it against the current directory of the drive named by the pathname, if any; if not, it is resolved against the current user directory.

Returns:

String The absolute pathname string

### getLength

    Number getLength()

Returns the length of the file represented by this File object.
The return value is unspecified if this pathname denotes a directory.

Returns:

Number The length, in bytes, of the file, or 0L if the file does not exist

### getName

    String getName()

Returns the name of the file or directory represented by this File object.
This is just the last name in the pathname's name sequence. If the pathname's name sequence is empty, then the empty string is returned.

Returns:

String containing the name of the file or directory

### getParent

    String getParent()

Returns the pathname string of this File object's parent directory.

Returns:

String containing the pathname of the parent directory

### getPath

    String getPath()

Returns the pathname string of this File object.
The resulting string uses the default name-separator character to separate the names in the name sequence.

Returns:

String of this file's pathname

### isAbsolute

    Boolean isAbsolute()

Tests whether this File object's pathname is absolute.
The definition of absolute pathname is system dependent. On UNIX systems, a pathname is absolute if its prefix is "/". On Microsoft Windows systems, a pathname is absolute if its prefix is a drive specifier followed by "\\", or if its prefix is "\\".

Returns:

Boolean if this abstract pathname is absolute, false otherwise

### isDirectory

    Boolean isDirectory()

Tests whether the file represented by this File object is a directory.

Returns:

Boolean true if this File object is a directory and exists; false otherwise

### isFile

    Boolean isFile()

Tests whether the file represented by this File object is a normal file.
A file is normal if it is not a directory and, in addition, satisfies other system-dependent criteria. Any non-directory file created by a Java application is guaranteed to be a normal file.

Returns:

Boolean true if this File object is a normal file and exists; false otherwise

### isOpened

    Boolean isOpened()

Returns true if the file represented by this File object is currently open.

Returns:

Boolean

### lastModified

    Number lastModified()

Returns the time when the file represented by this File object was last modified.
A number representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or 0L if the file does not exist or if an I/O error occurs.

Returns:

Number in milliseconds since 00:00:00 GMT, January 1, 1970

### list

    Object list(<RegExp> pattern)

List of all files within the directory represented by this File object.
You may pass a RegExp Pattern to return just files matching this pattern.
Example:

     var xmlFiles = dir.list(/.*\.xml/);

Parameters:

`pattern` - as RegExp, optional pattern to test each file name against

Returns:

Array the list of file names

### mkdir

    Boolean mkdir()

Creates the directory represented by this File object.

Returns:

Boolean true if the directory was created; false otherwise

### open

    Boolean open()

Opens the file represented by this File object.

Returns:

Boolean

### readAll

    String readAll()

This methods reads all the lines contained in the file and returns them.

Returns:

String of all the lines in the file

### readln

    String readln()

This methods reads characters until an end of line/file is encountered then returns the string for these characters (without any end of line character).

Returns:

String of the next unread line in the file

### remove

    Boolean remove()

Deletes the file or directory represented by this File object.

Returns:

Boolean

### renameTo

    Boolean renameTo(<String> dest)

Renames the file represented by this File object.
Whether or not this method can move a file from one filesystem to another is platform-dependent. The return value should always be checked to make sure that the rename operation was successful.

Parameters:

`dest` - as String, new pathname for the named file

Returns:

true if the renaming succeeded; false otherwise

### write

    Boolean write(<String> data)

Appends a string to the file represented by this File object.

Parameters:

`data` - as String, to be written to the file

Returns:

Boolean

See:

- writeln()

### writeln

    Boolean writeln(<String> data)

Appends a string with a platform specific end of line to the file represented by this File object.

Parameters:

`data` - as String, to be written to the file

Returns:

Boolean

See:

- write()

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007