This tip shows a program which deletes files with a certain extension.

 import java.io.File;
import java.io.FilenameFilter;
import java.lang.*;

public class delfile {

   public static void main (String args[]) {
     System.out.println("hello");
     delfile td = new delfile();
     td.deleteFiles("c:/test/", ".gif");
   }

   public void deleteFiles( String d, String e ) {

     ExtensionFilter filter = new ExtensionFilter(e);
     File dir = new File(d);

     String[] list = dir.list(filter);
     File file;
     if (list.length == 0) return;

     for (int i = 0; i < list.length; i++) {
       file = new File(d + list[i]);
       boolean isdeleted =   file.delete();
       System.out.print(file);
       System.out.println( "  deleted " + isdeleted);
     }
   }

   class ExtensionFilter implements FilenameFilter {

     private String extension;

     public ExtensionFilter( String extension ) {
       this.extension = extension;             
     }
     public boolean accept(File dir, String name) {
       return (name.endsWith(extension));
     }
   }
}