code: private static void recursiveDelete(File f) throws IOException
     {
        if (f != null && f.exists())
        {
           File[] files = f.listFiles();
           if (files != null)
           {
              for (int i = 0; i < files.length; i++)
              {
                 if (files[i].isDirectory())
                 {
                    recursiveDelete(files[i]);
                 }
                 else
                 {
                    if (!files[i].delete())
                       throw new IOException("Could not delete " + files[i]);
                 }
              }
           }
           if (!f.delete())
              throw new IOException("Could not delete " + f);
        }
     }
docs: Recursive delete
  @param f The file handler
  @exception IOException Thrown if a file could not be deleted