import java.io.*; import java.util.*; import javax.microedition.io.file.*; import javax.microedition.io.*; public class fileSystem{ public String[] List (String path) throws IOException { Vector vFiles; if (path.equals("/")) { vFiles = new Vector (); Enumeration rootEnum = FileSystemRegistry.listRoots(); while (rootEnum.hasMoreElements()) { String root = (String)rootEnum.nextElement(); vFiles.addElement(root); } String[] list =new String[vFiles.size()]; vFiles.copyInto(list); vFiles.removeAllElements(); vFiles = null; return list; } else if (path.length() > 1) { vFiles = new Vector (); FileConnection fconn =(FileConnection)Connector.open("file://" + path); for(Enumeration e =fconn.list("*", false) ; e.hasMoreElements() ;) { vFiles.addElement(e.nextElement()); } fconn.close(); String[] list = new String[vFiles.size()]; vFiles.copyInto(list); vFiles.removeAllElements(); vFiles = null; return list; } else { throw new IOException("List() : invalid path"); } } }