Here you can find the source of delete(final Path path)
public static void delete(final Path path)
//package com.java2s; //License from project: Open Source License import java.io.IOException; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.Path; public class Main { public static void delete(final Path path) { if (Files.exists(path)) { try { if (Files.isDirectory(path)) { try (DirectoryStream<Path> stream = Files.newDirectoryStream(path)) { stream.forEach((entry) -> delete(entry)); }/*ww w. j a v a 2 s .c om*/ } Files.delete(path); } catch (IOException e) { throw new Error(e); } } } }