code: public void cleanDirectory( final File directory )
          throws IOException
      {
          if ( !directory.exists() )
          {
              final String message = directory + " does not exist";
              throw new IllegalArgumentException( message );
          }
  
          if ( !directory.isDirectory() )
          {
              final String message = directory + " is not a directory";
              throw new IllegalArgumentException( message );
          }
  
          Delete deleteTask = new Delete();
          deleteTask.setProject(getProject());
  		deleteTask.setDir(directory);
  		deleteTask.execute();
  		
  		if(!directory.exists()){
  			directory.mkdirs();
  		}
      }
docs: Clean a directory without deleting it.