Java Reference
In-Depth Information
getURL : Returns the path and file name in the form used by Connector for opening
the file (including the GCF URL protocol)
isDirectory : Returns true if the specific FileConnection refers to a directory
isHidden : Returns true if the FileConnection refers to a hidden file
isOpen : Returns true if the current FileConnection is open
lastModified : Returns the last time the file was modified
setHidden : Lets you change the visibility status of a file
setReadable : Lets you change the readable attribute of a file
setWritable : Lets you change the writable attribute of a file
truncate : Lets you truncate a file to a specific length
Of course, all of these can throw an exception, so be prepared to handle any they offer.
Deleting a File or Directory
You can delete a file or directory using the FileConnection.delete method, which
immediately deletes the indicated file or directory. If other streams are associated with
the file, they will be flushed and closed automatically; continuing to work with them
will result in an IOException . The FileConnection itself, however, remains open and
available for reuse (say, to create a new file with the same name).
Enumerating a Directory's Contents
If you want to obtain a list of the contents of a directory, you can do so using the
FileConnection.list method, which returns an Enumeration of the directory's contents.
FileConnection.list comes in two flavors: one that takes no arguments and shows all files
in a specific directory, and one that takes a wildcard-capable string and a boolean indicat-
ing whether hidden files should be included in the resulting Enumeration .
If you need to manipulate a file or directory returned by the Enumeration , you don't
need to go through the gymnastics of creating a new FileConnection by constructing a
GCF-compliant URL for the file or directory in question. Instead, you can pass a string
from the Enumeration directly to the FileConnection that opened the Enumeration using the
setFileConnection method. This method resets the FileConnection to refer to the file or
directory you pass to it.
 
Search WWH ::




Custom Search