trying NIO and got two problems.1)
create dir files and two inner dirs with file in last dir.

```
Path pathDir = Path.of("files", "firstDir", "secondDir");
Path pathFile = Path.of("files", "firstDir", "secondDir", "file.txt");

Files.createDirectories(pathDir);
Files.createFile(pathFile);

```

is there any way to combine this into one expression so as not to create folders and files separately?  

2) deleting file with dirs

```
Files.deleteIfExists(pathFile); //delete only file
Files.deleteIfExists(pathDir); // delete only last dir secondDir  

```

deletes one item at a time, how to delete all folders and a file at once?

I found such an example, but it also deletes only the file

```
 Files.walk(pathFile)
            .sorted(Comparator.reverseOrder())
            .map(Path::toFile)
            .forEach(File::delete);  

```

and this option deletes only one file

```
try {
    Files.walkFileTree(pathFile, new SimpleFileVisitor<Path>() {
        @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();
}

```