0

We writed java program, it deletes directory on some shared network disc. But it is very slow. It uses recursion for directories deletion (in function commons-io FileUtils.deleteDirectory). But I think recursion is slow, because there is a lot of network communication.

Is some way, how to delete directory with content by one "command"?

user3706629
  • 209
  • 2
  • 9
  • Have a look at [`java.nio.file.Files`](https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html) and its method [`walkFileTree`](https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#walkFileTree(java.nio.file.Path,%20java.nio.file.FileVisitor)) – deHaar Jun 19 '20 at 07:02
  • Thanks deHaar, but I do not want to walk file tree and delete individual files. I think it is slow. I would like to send one delete command to other system. For example in webdav it is one command delete, which deletes directory and its content (http://www.webdav.org/specs/rfc4918.html#delete-collections). I hope, that it is possible with windows shares (CIFS protocol) too. But I don´t know how to do it. – user3706629 Jun 22 '20 at 18:14

1 Answers1

0

We use commands

del /f/s/q foldername > nul

rmdir /s/q foldername

on Windows, i.e. we call theese commands from Java.

See What's the fastest way to delete a large folder in Windows?

It isn't too nice, but it works :-).