| de.schlund.pfixxml.resources.FileResource
FileResource | public interface FileResource extends Comparable<FileResource>(Code) | | Provides access to files. This interface is similar to the
java.io.File object, but is more flexible. You usually
should not create your own classes implementing this interface
but use the
de.schlund.pfixxml.resources.ResourceUtil class to retrieve instances of this class.
Note that depending on the system state, some methods might not
be available, especially methods which modify a resource. These
methods will then behave like being used on a file that is not
writable. Note also the special behaviour of the
FileResource.lastModified() method which is different from the behaviour
of the corresponding method in the File class.
See Also: de.schlund.pfixxml.resources.ResourceUtil author: Sebastian Marsching |
Method Summary | |
boolean | canRead() Tests whether the application can read the resource denoted by this
object. | boolean | canWrite() Tests whether the application can modify the resource denoted by this
object. | boolean | createNewFile() Atomically creates a new, empty file resource identified by this object if
and only if a file with this name does not yet exist. | boolean | delete() Deletes the file or directory denoted by this file resource. | boolean | exists() Tests whether the file or directory denoted by this file resource exists. | InputStream | getInputStream() Returns a stream which can be used for reading the content of
the resource denoted by this object. | String | getName() Returns the name of the file or directory denoted by this file resource.
This is just the last name in the pathname's name sequence. | OutputStream | getOutputStream() Returns a which can be used for writing to the resource
denoted by this object. | OutputStream | getOutputStream(boolean append) | FileResource | getParentAsFileResource() Returns the file resource matching this file resource's parent,
or null if this file resource does not have a parent
directory.
The parent of an file resource consists of the
pathname's prefix, if any, and each name in the pathname's name
sequence except for the last. | boolean | isDirectory() Tests whether the resource denoted by this file resource is a
directory. | boolean | isFile() Tests whether the file denoted by this object is a normal
file. | boolean | isHidden() Tests whether the file named by this file resource is a hidden
file. | long | lastModified() Returns the time that the file denoted by this resource was
last modified. | String[] | list() Returns an array of strings naming the files and directories in the
directory denoted by this resource.
If this resource does not denote a directory, then this
method returns null . | FileResource[] | listFileResources() Returns an array of file resource denoting the files in the
directory denoted by this file resource.
If this file resource does not denote a directory, then this
method returns null . | boolean | mkdir() Creates the directory named by this file resource. | boolean | mkdirs() Creates the directory named by this file resource, including any
necessary but nonexistent parent directories. | URI | toURI() | URL | toURL() Returns an URL which can be used in order to access the
file donoted by this object. |
canRead | boolean canRead()(Code) | | Tests whether the application can read the resource denoted by this
object.
true if and only if the resource specified by thisobject exists and can be read by the application; false otherwise |
canWrite | boolean canWrite()(Code) | | Tests whether the application can modify the resource denoted by this
object.
true if and only if the resource denoted by this object exists and the application is allowed to write to the resource; false otherwise. |
createNewFile | boolean createNewFile() throws IOException(Code) | | Atomically creates a new, empty file resource identified by this object if
and only if a file with this name does not yet exist. The check for the
existence of the file and the creation of the file if it does not exist
are a single operation that is atomic with respect to all other
filesystem activities that might affect the file.
Note: this method should not be used for file-locking, as
the resulting protocol cannot be made to work reliably. The
java.nio.channels.FileLock FileLock facility should be used instead.
true if the named file does not exist and wassuccessfully created; false if the named filealready exists throws: IOException - If an I/O error occurred |
delete | boolean delete()(Code) | | Deletes the file or directory denoted by this file resource. If
this resource denotes a directory, then the directory must be empty in
order to be deleted.
true if and only if the file or directory issuccessfully deleted; false otherwise |
exists | boolean exists()(Code) | | Tests whether the file or directory denoted by this file resource exists.
true if and only if the file or directory denotedby this file resource exists; false otherwise |
getName | String getName()(Code) | | Returns the name of the file or directory denoted by this file resource.
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.
The name of the file or directory denoted by this file resource, or the empty string if this resource's name sequenceis empty |
getParentAsFileResource | FileResource getParentAsFileResource()(Code) | | Returns the file resource matching this file resource's parent,
or null if this file resource does not have a parent
directory.
The parent of an file resource consists of the
pathname's prefix, if any, and each name in the pathname's name
sequence except for the last. If the name sequence is empty then
the pathname does not name a parent directory.
The file resource matching the parent directory named by thisfile resource, or null if this file resourcedoes not name a parent since: 1.2 |
isDirectory | boolean isDirectory()(Code) | | Tests whether the resource denoted by this file resource is a
directory.
true if and only if the resource denoted by thisobject exists and is a directory;false otherwise |
isFile | boolean isFile()(Code) | | Tests whether the file denoted by this 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.
true if and only if the file denoted by thisfile resource exists and is a normal file;false otherwise |
isHidden | boolean isHidden()(Code) | | Tests whether the file named by this file resource is a hidden
file. The exact definition of hidden is system-dependent. On
UNIX systems, a file is considered to be hidden if its name begins with
a period character ('.' ). On Microsoft Windows systems, a file is
considered to be hidden if it has been marked as such in the filesystem.
true if and only if the file denoted by thisresource is hidden according to the conventions of theunderlying platform |
lastModified | long lastModified()(Code) | | Returns the time that the file denoted by this resource was
last modified. Might return "-1" if the last modified time is
not available.
A long value representing the time the file waslast modified, measured in milliseconds since the epoch(00:00:00 GMT, January 1, 1970), or 0L if thefile does not exist or if an I/O error occurs |
list | String[] list()(Code) | | Returns an array of strings naming the files and directories in the
directory denoted by this resource.
If this resource does not denote a directory, then this
method returns null . Otherwise an array of strings is
returned, one for each file or directory in the directory. Names
denoting the directory itself and the directory's parent directory are
not included in the result. Each string is a file name rather than a
complete path.
There is no guarantee that the name strings in the resulting array
will appear in any specific order; they are not, in particular,
guaranteed to appear in alphabetical order.
An array of strings naming the files and directories in thedirectory denoted by this file resource. The array will beempty if the directory is empty. Returns null ifthis file resource does not denote a directory, or if anI/O error occurs. |
listFileResources | FileResource[] listFileResources()(Code) | | Returns an array of file resource denoting the files in the
directory denoted by this file resource.
If this file resource does not denote a directory, then this
method returns null . Otherwise an array of
FileResource objects is returned, one for each file or
directory in the directory. Resources denoting the directory itself and the
directory's parent directory are not included in the result.
There is no guarantee that the name strings in the resulting array
will appear in any specific order; they are not, in particular,
guaranteed to appear in alphabetical order.
An array of file resources denoting the files anddirectories in the directory denoted by this file resource.The array will be empty if the directory is empty. Returns null if this abstract pathname does not denotea directory, or if an I/O error occurs. |
mkdir | boolean mkdir()(Code) | | Creates the directory named by this file resource.
true if and only if the directory wascreated; false otherwise |
mkdirs | boolean mkdirs()(Code) | | Creates the directory named by this file resource, including any
necessary but nonexistent parent directories. Note that if this
operation fails it may have succeeded in creating some of the necessary
parent directories.
true if and only if the directory was created,along with all necessary parent directories; false otherwise |
toURI | URI toURI()(Code) | | Returns a normalized version of the URI which was used
in order to create this FileResource
URI representing this object |
toURL | URL toURL() throws MalformedURLException(Code) | | Returns an URL which can be used in order to access the
file donoted by this object.
URL suitable to access the resource denoted by this object throws: MalformedURLException - if this object does not contain a valid path |
|
|