![]() |
![]() The File object provides path and filesystem support: opening and removing files, listing directories, and retrieving file attributes. Paths are always URLs, using '/' to separate path components. Resin takes care of translating URLs into their system specific file names.
Returns a new file object. The
is any URL.
uses forward slashes to separate directories, even on
non-unix operating systems.
Returns a new file object.
is a path relative
to the file.
Returns the scheme of the file.
Returns the host of the file. If the scheme does not
support hosts, e.g. file:, it will return null.
Returns the port of the file. If the scheme does not
support ports, e.g. file:, it will return 0.
Returns the path of the file.
Returns true if the file refers to a file, directory or other object
in the filesystem.
Contains the mime-type of the object. Filesystems which are not
mime-aware return 'application/octet-stream'.
Returns true if the file refers to a directory.
Returns true if the file refers to a file, i.e. something which can be
read by a stream.
Returns the length of the file in bytes.
Returns 0 for non-files.
Returns the last modified time of the file. According to the JDK,
this may not correspond to system clock time.
Tests if this file can be read.
Tests if this file can be written to.
Logging code can use this to write to a log only when enabled:
The contents of this directory or null if the file does not
refer to a directory.
Returns an iterator (jdk1.2 collection) of the contents of the
directory.
The following example writes the filenames of the current working directory.
Creates the directory named by the file. The parent directory must
exist.
Creates the directory named by the file and any parent directories if
necessary.
The following example creates a temp directory
Removes the directory or file named by the file.
The following example removes all files in the current directory.
Renames the file or directory to the new file. The parameter may
either be a file object or a string.
Creates a restricted File object. The restricted File only
has access to children of the new root object. An absolute path will
refer to the created root, not the root of the parent filesystem.
The following JSP example is safe, even though it returns a file given a query string. Normally, that's a big security mistake.
Opens a stream for reading.
Opens a stream for writing.
Opens a stream for writing.
Opens a stream for reading and writing.
Streams open for read/write have all the methods of both read streams and write streams In addition, they ensure that writes are flushed before reads.
Convenience function writes the string to the file.
The following example sends a mail message containing the single line "subscribe".
|