Here you can find the source of deleteFolder(Path folder)
public static void deleteFolder(Path folder)
//package com.java2s; //License from project: Apache License import java.io.File; import java.nio.file.Path; public class Main { public static void deleteFolder(Path folder) { if (folder.toFile().exists() && folder.toFile().isDirectory()) { System.out.println("deleting " + folder.toAbsolutePath()); deleteRecursive(folder.toFile()); }/*from w w w . j ava2s .com*/ } static void deleteRecursive(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); if (files != null) { for (File f : files) { deleteRecursive(f); } if (!file.delete()) { System.out.println("Could not delete folder " + file); } } } else { if (!file.delete()) { System.out.println("Could not delete file " + file); } } } }