9

Delete folder - delete files in folder - J2ME

 2 years ago
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

advertisements

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?

Hi i am relatively new to windows service. I want to create a schedule task that will go through certain folder like c://dev/ and delete the files that are created between some date/time. How can i achieve this?Any help really appriciated...Check thi

How to delete files automatically in a folder in ubuntu?

How to automatic deleting files to a folder in ubuntu? I need to do a script to delete files from a folder that is filled with the execution of a process on my server.The proper command would be rm -rf folder/ to delete files recursively from that pa

How can you delete files in a folder that corresponds to a regular expression using PowerShell?

I know a common characteristic of the file names of a number of unwanted files on my Windows computer. How can I remove all of these files from a given folder or folder hierarchy with a single regular expression PowerShell command?You can pipe a Get-

Delete files from a particular folder automatically in aws s3 bucket

strong textI want to delete files from s3 bucket.Inside "test" bucket,there is folder named "mi" and inside mi "archive". I configured life cycle rule on "test" bucket to delete file abc.txt from "test/mi/archi

Deleting files from a folder - Android

I have a folder which contains some files that I want to deleted after processing them. The files have the extension .FIR After some googling I found a recursive method that I modified a bit: void delete(File f) throws IOException { if (f.isDirectory

Batch file to recursively delete files in a folder of more than N number of days

I'm using a batch file now to delete all files ending in .snp that are older than 180 days. The code below works to delete all files ending in .snp under the root folder C:\Program Files\Snapshots But I recently discovered that within the Snapshots f

Git: How to commit a deleted file manually?

This question already has an answer here: Delete files from git index when they are already deleted from fs 5 answers Staging Deleted files 6 answers In my git repository I manually deleted a file(rm) after moving it to another folder. I than committ

How to delete files in a specific subfolder?

So far I have tried this: For /R "C:\Test\" %%G IN (*.*) do del "%%G" With this code it deletes all files starting from c:\test\ but I want to delete files on a specific subfolder. Any suggestions?This will delete the visible files fro

How do I get 2013 TFS to detect deleted files in the file system?

When I delete a file in the file system, TFS 2013 will correctly show it as still being in version control, but the file will not show as pending delete, and committing changes does not remove the file from the server. If I go to Source Code Explorer

Batch script to delete files in a directory after a certain count value

I am currently looking to implement a small script to browse through a directory and delete all files/folders after a certain count value in this case ill use 3 This is an example of what i'm trying to achieve c:/test Contains file1.bak file2.bak fil

How to delete files with a lifetime of X days, not last modified. Is it even possible? Linux

I run some kind of server on my linux machine and I use simple bash script to delete files every 3 and some files every 7 days. I use find command for doing that.But my files are saved periodically, meaning that the last modification day is the curre

Obtaining Administrator Privileges to Delete Files Using rm from a Cocoa Application

I am making a small app that deletes log files. I am using an NSTask instance which runs rm and srm (secure rm) to delete files. I want to be able to delete files in: /Library/Logs ~/Library/Logs The issue is that the user account does not have permi

MSBuild Task Syntax to Delete Files

I'm trying to write a MSBuild Task that deletes the Obj directory and PDBs from my bin folder on my production build scripts and can't seem to get it to work right. Does anyone have an example where they do this or similar, or a link to a simple exam

How to delete files from HDFS?

I just downloaded Hortonworks sandbox VM, inside it there are Hadoop with the version 2.7.1. I adding some files by using the hadoop fs -put /hw1/* /hw1 ...command. After it I am deleting the added files, by the hadoop fs -rm /hw1/* ...command, and a

Deleting files that were used in a C # LibraryStack in a Scatterview

I'm new to C#/WPF/Surface programming. I'm using a LibraryStack in a ScatterViewItem in a ScatterView: <Grid Name="DataGrid" Background="LightBlue" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> &l

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK