Delete all Files From Folder





13
Date Submitted Mon. Mar. 20th, 2006 4:52 PM
Revision 1 of 1
Coder mattrmiller
Tags Delete | Extension | File | Folder | Java
Comments 0 comments
Deletes all files of a certain extention from a folder.


// Clears folder from the mess we make
public static void clearFolder(String strFolder, String strExt)
{
        // Declare variables
        File fLogDir = new File(strFolder);
       
        // Get all BCS files
        File[] fLogs = fLogDir.listFiles(new FilenameFilter()
        {
                public boolean accept(File fDir, String strName)
                {
                        return (strName.endsWith("." + strExt));
                }
        });
       
        // Delete all files
        for (int i = 0; i < fLogs.length; i++)
        {
                deleteFile(fLogs[i].getAbsolutePath());
        }
}

 

Matthew R. Miller

www.bluecreststudios.com
=================
Matthew R. Miller

http://bluecreststudios.com
http://www.codeandcoffee.com

Comments

There are currently no comments for this snippet.

Voting