FileDocCategorySizeDatePackage
DirLister.javaAPI DocExample1716Thu Feb 16 11:44:52 GMT 2006None

DirLister

public class DirLister extends MIDlet

Fields Summary
private int
level
Constructors Summary
Methods Summary
public voiddestroyApp(boolean condition)

    notifyDestroyed();
  
private voidgetInfo(FileConnection connection, Form form)

 
    if (connection.isDirectory()) form.append("------\n");
    for (int i = 0; i < level; i++) form.append(" ");
    form.append(connection.getPath() + connection.getName() + "\n");
    if (connection.isDirectory()) {
      level++;
      Enumeration list = connection.list();
      String path =  connection.getPath() + connection.getName();
      while (list.hasMoreElements()) {
        Object next = list.nextElement();
        String url = "file://" + path + next ;
        try {
          FileConnection child = (FileConnection) Connector.open(url);
          getInfo(child, form);
        }
        catch (Exception ex) {
          form.append(ex.getMessage() +"\n");
        }
      }
      level--;
    }  
  
public voidpauseApp()

public voidstartApp()

    
      
     Form form = new Form("File Roots");
     Enumeration roots = FileSystemRegistry.listRoots();
     while (roots.hasMoreElements()) {
       Object next = roots.nextElement();
       String url = "file:///" + next;
       System.out.println(url);
       try {
         FileConnection connection = (FileConnection) Connector.open(url);
         getInfo(connection, form);
       }
       catch (IOException ex) {
         form.append(ex.getMessage() +"\n");
       }
     }
     Display.getDisplay(this).setCurrent(form);