IMHO, path.delete() looks better than Files.delete(path) .

But the developers of the java.nio.file package preferred to implement Path operations through the static methods of the Files class. Why?

That is, the Path interface could be replaced with an abstract class with the methods delete() , isDirectory() , etc., in the same way having a convenient mechanism for implementing platform-dependent entities.

  • what's the point in the path object after calling delete ()? the path / link / file is deleted and the object itself is what? * PHP: unlink * Delphi: RemoveDir * C ++: boost :: filesystem :: remove_all , etc. - Yura Ivanov
  • @Yura Ivanov, in contrast, I offer juFile.delete () . The object continues to describe a certain path, but not yet created. - Nofate
  • @Yura Ivanov, in PHP unlink still appeared too early to be an alternative. - etki
  • @Nofate, that's right, if we work with a file, then we can create it, modify it, delete it, etc. and if you only need to delete, why create an object? besides, these methods are different in functionality ... And as an answer to the question, you can see that there is one and the other option. - Yura Ivanov
  • @Yura Ivanov, so I do not refute your point of view. I have more with the purpose to add an example offered. - Nofate

0