title: Java.nio: most concise recursive directory delete
body: <p>I am currently trying to recursively delete a directory... Strangely enough the shortest piece of code I was able to find is the following construct, employing an <em>ad-hoc inner class</em> and in a <em>visitor pattern</em>...</p>
  
  <pre><code>Path rootPath = Paths.get("data/to-delete");
  
  try {
    Files.walkFileTree(rootPath, new SimpleFileVisitor&lt;Path&gt;() {
      @Override
      public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
        System.out.println("delete file: " + file.toString());
        Files.delete(file);
        return FileVisitResult.CONTINUE;
      }
  
      @Override
      public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
        Files.delete(dir);
        System.out.println("delete dir: " + dir.toString());
        return FileVisitResult.CONTINUE;
      }
    });
  } catch(IOException e){
    e.printStackTrace();
  }
  </code></pre>
  
  <p>Source: <a href="http://tutorials.jenkov.com/java-nio/files.html#deleting-directories-recursively" rel="noreferrer">here</a></p>
  
  <p>This feels horribly clumsy and verbose, given that the new <code>nio</code> APIs remove so much clutter and boilerplate...</p>
  
  <p><strong>Is there any shorter way of achieving a forced, recursive directory delete?</strong></p>
  
  <p>I'm looking for pure native Java 1.8 methods, so please don't link to external libraries...</p>