Constructor
new File(path)
Constructor for File objects, providing read and
write access to the file system.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | as String, can be either absolute or relative to the helma home directory |
- Source:
Methods
canRead()
Tests whether the application can read the file
represented by this File object.
- Source:
Returns:
Boolean true if the file exists and can be read; false otherwise
canWrite()
Tests whether the file represented by this File object is writable.
- Source:
Returns:
Boolean true if the file exists and can be modified; false otherwise.
clearError()
Clears any error message that may otherwise be returned by the error method.
- Source:
- See:
close()
Closes the file represented by this File object.
- Source:
Returns:
Boolean
eof()
Returns true if the file represented by this File object
has been read entirely and the end of file has been reached.
- Source:
Returns:
Boolean
error()
Contains the last error that occured, if any.
- Source:
- See:
Returns:
String
exists()
Tests whether the file or directory represented by this File object exists.
- Source:
Returns:
Boolean true if the file or directory exists; false otherwise
flush()
Purges the content of the file represented by this File object.
- Source:
Returns:
Boolean
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.
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.
- Source:
Returns:
String The absolute pathname string
getLength()
Returns the length of the file represented by this File object.
The return value is unspecified if this pathname denotes a directory.
The return value is unspecified if this pathname denotes a directory.
- Source:
Returns:
Number The length, in bytes, of the file, or 0L if the file does not exist
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.
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.
- Source:
Returns:
String containing the name of the file or directory
getParent()
Returns the pathname string of this File object's parent directory.
- Source:
Returns:
String containing the pathname of the parent directory
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.
The resulting string uses the default name-separator character to separate the names in the name sequence.
- Source:
Returns:
String of this file's pathname
hardCopy(dest)
Makes a copy of a file over partitions.
Parameters:
Name | Type | Description |
---|---|---|
dest |
String | helma.File | as a File object or the String of full path of the new file |
- Source:
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 "\\".
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 "\\".
- Source:
Returns:
Boolean if this abstract pathname is absolute, false otherwise
isDirectory()
Tests whether the file represented by this File object is a directory.
- Source:
Returns:
Boolean true if this File object is a directory and exists; false otherwise
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.
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.
- Source:
Returns:
Boolean true if this File object is a normal file and exists; false otherwise
isOpened()
Returns true if the file represented by this File object
is currently open.
- Source:
Returns:
Boolean
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.
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.
- Source:
Returns:
Number in milliseconds since 00:00:00 GMT, January 1, 1970
list(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/);
You may pass a RegExp Pattern to return just files matching this pattern.
Example: var xmlFiles = dir.list(/.*\.xml/);
Parameters:
Name | Type | Description |
---|---|---|
pattern |
RegExp | as RegExp, optional pattern to test each file name against |
- Source:
Returns:
Array the list of file names
listRecursive(pattern)
Recursivly lists all files below a given directory
you may pass a RegExp Pattern to return just
files matching this pattern.
Parameters:
Name | Type | Description |
---|---|---|
pattern |
RegExp | as RegExp, to test each file name against |
- Source:
Returns:
Array the list of absolute file paths
makeDirectory()
Creates the directory represented by this File object.
- Source:
Returns:
Boolean true if the directory was created; false otherwise
move(dest)
Moves a file to a new destination directory.
Parameters:
Name | Type | Description |
---|---|---|
dest |
String | as String, the full path of the new file |
- Source:
Returns:
Boolean true in case file could be moved, false otherwise
open(options)
Opens the file represented by this File object. If the file exists,
it is used for reading, otherwise it is opened for writing.
If the encoding argument is specified, it is used to read or write
the file. Otherwise, the platform's default encoding is used.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object | an optional argument holder object.
The following options are supported:
|
- Source:
Returns:
Boolean true if the operation succeeded
readAll()
This methods reads all the lines contained in the
file and returns them.
- Source:
Returns:
String of all the lines in the file
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).
- Source:
Returns:
String of the next unread line in the file
remove()
Deletes the file or directory represented by this File object.
- Source:
Returns:
Boolean
removeDirectory()
This method removes a directory recursively .
DANGER! DANGER! HIGH VOLTAGE! The directory is deleted recursively without any warning or precautious measures.
DANGER! DANGER! HIGH VOLTAGE! The directory is deleted recursively without any warning or precautious measures.
- Source:
renameTo(toFile)
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.
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:
Name | Type | Description |
---|---|---|
toFile |
FileObject | as FileObject of the new path |
- Source:
Returns:
true if the renaming succeeded; false otherwise
toByteArray()
Returns file as ByteArray.
Useful for passing it to a function instead of an request object.
Useful for passing it to a function instead of an request object.
- Source:
write(what)
Appends a string to the file represented by this File object.
Parameters:
Name | Type | Description |
---|---|---|
what |
String | as String, to be written to the file |
- Source:
- See:
Returns:
Boolean
writeln(what)
Appends a string with a platform specific end of
line to the file represented by this File object.
Parameters:
Name | Type | Description |
---|---|---|
what |
String | as String, to be written to the file |
- Source:
- See:
Returns:
Boolean