The API contains one class, two interfaces, and two exceptions.
The most important one of these is the FileConnection
interface, which extends the Connection
interface
and gives access to directories and individual files.
Implementations of FileConnection
are created
using the Connector.open()
method. The argument
of the open()
method is a URL with the format file://<host>/<path>
, as defined in RFC 1738 and RFC 2396 (RFC is the Request for Comments repository maintained
by the IETF Secretariat), where host
is normally
left empty and path
starts with the root of the
file system down to a particular file or directory. An example of
a typical file URL in a Symbian device looks as follows:
file:///C:/data/Images/Image(001).jpg
The roots of the file system are device-specific and they don't
necessarily correspond to physical memory units since they are logically
defined by the device's operating system. Furthermore, some Nokia
devices support virtual roots and virtual directories, which act as
links pointing to certain denoted directories. For example, c:/
and e:/
are physical roots. The
corresponding virtual roots are Internal/
and Memory card/
. Virtual directories map to the same directories
that are defined in FC API System properties . This makes it easier
to find locations and also eases the security permissions, given that
a MIDlet may have access rights to the Internal/Images
root but not necessarily to the c:/
root. For
more information on virtual file systems, see FC API Implementation
notes.
The FileSystemRegistry
class provides the listRoots()
utility method that returns an enumeration
of the roots on the file system. This includes both logical and virtual
roots. The API also takes into account that certain devices have the
ability to have file systems added or removed at run time. The FileSystemRegistry
class provides methods for registering FileSystemListener
listeners that are called when the
roots on the device are modified. It is recommended for every application
to register a FileSystemListener
listener to
be informed about these changes and act accordingly.
Since the FC API is an optional extension, a system property has
been added to indicate the API's presence. The microedition.io.file.FileConnection.version
system property contains the implemented version of the API. Currently
this property should have the value 1.0
to indicate
the current status of the API or null if the API is not present. Another
useful system property is file.separator
, which
contains the character used to separate directories in strings.