Java Directory Delete nio deleteDirectory(File path)

Here you can find the source of deleteDirectory(File path)

Description

delete Directory

License

Open Source License

Declaration

static void deleteDirectory(File path) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.IOException;
import java.nio.file.FileVisitOption;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Comparator;
import java.util.stream.Stream;

public class Main {
    static void deleteDirectory(File path) {
        try (Stream<Path> walk = Files.walk(path.toPath(), FileVisitOption.FOLLOW_LINKS)) {
            walk.sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete);
        } catch (IOException ignored) {
        }/*from   w ww .  java 2s .  c  o  m*/
    }
}

Related

  1. deleteDirectory(File directory)
  2. deleteDirectory(File directory)
  3. deleteDirectory(File directory)
  4. deleteDirectory(File directory)
  5. deleteDirectory(File file)
  6. deleteDirectory(final File directory)
  7. deleteDirectory(final Path dir, final int maxDepth)
  8. deleteDirectory(Path dir)
  9. deleteDirectory(Path directory)