Does any one know where there is some Java code already written to handle deleteing directory trees? Maybe with some undo functions?

I'm sure that you can use Google to search for existing code. You can write it by yourself, all the information you need is in the File class.

I'm sure that you can use Google to search for existing code. You can write it by yourself, all the information you need is in the File class.

I did not ask for your opion apines. This forum is to find code not to stroke your ego.
Stating the obvious is not very helpful. I will have code soon that you can learn from. clearly you need this.

commented: Show some effort before asking people to do your work for you. -1

Actually this forum is to help and guide with problems and not to do your work for you.

Actually this forum is to help and guide with problems and not to do your work for you.

I did not start this post to be inhibited by your chit chat.
I am building the code if you have nothing more.
your post are of no use. I asked if someone knew of the existence of code already written
I did not ask you to write it.

/**
   * Deletes a file or directory, allowing recursive directory deletion. This is an
   * improved version of File.delete() method.
   */
  public static boolean delete(String filePath, boolean recursive) {
      File file = new File(filePath);
      if (!file.exists()) {
          return true;
      }

      if (!recursive || !file.isDirectory())
          return file.delete();

      String[] list = file.list();
      for (int i = 0; i < list.length; i++) {
          if (!delete(filePath + File.separator + list[i], true))
              return false;
      }

      return file.delete();
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.