* @param root
* The file path to be enumerated
*/
private void enumerateDirectory(final String root) {
if (root != null) {
FileConnection fc = null;
Enumeration rootEnum = null;
// Open the file system and get the list of directories/files
try {
fc = (FileConnection) Connector.open(root);
rootEnum = fc.list();
} catch (final IOException e) {
SendMenuDemo.errorDialog(e.toString());
return;
} finally {
if (fc != null) {
// Everything is read, make sure to close the connection
try {
fc.close();
fc = null;
} catch (final IOException e) {
}
}
}
if (rootEnum != null) {
// Read through the list of directories/files
while (rootEnum.hasMoreElements()) {
final String file = root + (String) rootEnum.nextElement();
try {
fc = (FileConnection) Connector.open(file);
if (!fc.isDirectory()) {
_model.addRow(file);
}
} catch (final IOException e) {
System.out.println("Connector.open(" + file
+ ") threw " + e.toString());
}
}
if (fc != null) {
// Everything is read, close the connection.
try {
fc.close();
fc = null;
} catch (final Exception ioex) {
}
}
}