Delete folder - delete files in folder - J2ME
source link: https://www.codesd.com/item/delete-folder-delete-files-in-folder-j2me.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Delete folder - delete files in folder - J2ME
I am trying to clear all the files in a folder using j2me. How do I do that?
Since you are using J2ME, the java.io.File
class is not available to you.
So I am assuming that you are using the FileConnector Optional Package (FCOP).
Take a look at the javadocs for javax.microedition.io.file.FileConnection, and you should be able to figure out the details.
I'm not a J2ME expert, but I think that the code would 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, proper resource handling (using finally
) is left as an exercise for the reader :-)
Related Articles
How to create a Windows service to schedule a task such as deleting files on a certain folder?
How to delete files automatically in a folder in ubuntu?
How can you delete files in a folder that corresponds to a regular expression using PowerShell?
Delete files from a particular folder automatically in aws s3 bucket
Deleting files from a folder - Android
Batch file to recursively delete files in a folder of more than N number of days
Git: How to commit a deleted file manually?
How to delete files in a specific subfolder?
How do I get 2013 TFS to detect deleted files in the file system?
Batch script to delete files in a directory after a certain count value
How to delete files with a lifetime of X days, not last modified. Is it even possible? Linux
Obtaining Administrator Privileges to Delete Files Using rm from a Cocoa Application
MSBuild Task Syntax to Delete Files
How to delete files from HDFS?
Deleting files that were used in a C # LibraryStack in a Scatterview
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK