IM Profile

com.siemens.icm.io.file
Class FileSystemRegistry

java.lang.Object
  extended bycom.siemens.icm.io.file.FileSystemRegistry

public class FileSystemRegistry
extends Object

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.

Since:
FileConnection 1.0
See Also:
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 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

addFileSystemListener

public 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. Multiple file system listeners can be added. If file systems are not supported on a device, false is returned from the method (this check is performed prior to security checks).

Parameters:
listener - The new FileSystemListener to be registered in order to handle adding/removing file system roots.
Returns:
boolean indicating if file system listener was successfully added or not
Throws:
SecurityException - if application is not given permission to read files.
NullPointerException - if listener is null.
See Also:
FileSystemListener, FileConnection

removeFileSystemListener

public static boolean removeFileSystemListener(FileSystemListener listener)
This method is used to remove a registered FileSystemListener. If file systems are not supported on a device, false is returned from the method.

Parameters:
listener - The FileSystemListener to be removed.
Returns:
boolean indicating if file system listener was successfully removed or not
Throws:
NullPointerException - if listener is null.
See Also:
FileSystemListener, FileConnection

listRoots

public static Enumeration listRoots()
This method returns the currently mounted root file systems on a device as String objects in an Enumeration. If there are no roots available on the device, a zero length Enumeration is returned. If file systems are not supported on a device, a zero length Enumeration is also returned (this check is performed prior to security checks).

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 ValueOpening 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());
   }
 

Returns:
an Eumeration of mounted file systems as String objects.
Throws:
SecurityException - if application is not given permission to read files.
See Also:
FileConnection

IM Profile

Submit a comment or suggestion Version 2.0 of IM Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.