Since you are using J2ME, the class is java.io.Filenot available to you.
Therefore, I assume that you are using the optional FileConnector package (FCOP).
Take a look at javadocs at javax.microedition.io.file.FileConnection and you should be able to figure out the details.
I am not a J2ME expert, but I think the code will look something like this:
FileConnection fconn = (FileConnection) Connector.open("file:///SomeDirectory");
Enumeration en = fconn.list();
while (en.hasMoreElements()) {
String name = en.nextElement();
FileConnection tmp = (FileConnection) Connector.open(
"file:///SomeDirectory/" + name);
tmp.delete();
tmp.close();
}
Exception handling, the correct processing of resources (using finally) is left as an exercise for the reader :-)
source
share