|
FileConnection Optional Package 1.0 Final Release |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.io.file.FileSystemRegistry
The FileSystemRegistry is a central registry for file system listeners interested in the adding and removing (or mounting and unmounting) of file systems on a device.
FileConnection
,
FileSystemListener
Method Summary | |
static boolean |
addFileSystemListener(FileSystemListener listener)
This method is used to register a FileSystemListener that is notified in case of adding and removing a new file system root. |
static java.util.Enumeration |
listRoots()
This method returns the currently mounted root file systems on a device as String objects in an Enumeration. |
static boolean |
removeFileSystemListener(FileSystemListener listener)
This method is used to remove a registered FileSystemListener. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static boolean addFileSystemListener(FileSystemListener listener)
listener
- The new FileSystemListener to be
registered in order to handle adding/removing file system roots. java.lang.SecurityException
- if application is not given
permission to read files.
java.lang.NullPointerException
- if listener is null
.FileSystemListener
,
FileConnection
public static boolean removeFileSystemListener(FileSystemListener listener)
listener
- The FileSystemListener to be removed. java.lang.NullPointerException
- if listener is null
.FileSystemListener
,
FileConnection
public static java.util.Enumeration listRoots()
The first directory in the file URI is referred to as the root, which corresponds to a logical mount point for a particular storage unit or memory. Root strings are defined by the platform or implementation and can be a string of zero or more characters ("" can be a valid root string on some systems) followed by a trailing "/" to denote that the root is a directory. Each root string is guaranteed to uniquely refer to a root. Root names are device specific and are not required to adhere to any standard. Examples of possible root strings and how to open them include:
Possible Root Value | Opening the Root |
---|---|
CFCard/ | Connector.open("file:///CFCard/"); |
SDCard/ | Connector.open("file:///SDCard/"); |
MemoryStick/ | Connector.open("file:///MemoryStick/"); |
C:/ | Connector.open("file:///C:/"); |
/ | Connector.open("file:////"); |
The following is a sample showing the use of listRoots to retrieve the available size of all roots on a device:
Enumeration rootEnum = FileSystemRegistry.listRoots(); while (e.hasMoreElements()) { String root = (String) e.nextElement(); FileConnection fc = Connector.open("file:///" + root); System.out.println(fc.availableSize()); }
java.lang.SecurityException
- if application is not given
permission to read files.FileConnection
|
Final Release Rev. 1.00 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |