Java Path Delete nio delete(final Path path)

Here you can find the source of delete(final Path path)

Description

delete

License

Open Source License

Declaration

public static void delete(final Path path) 

Method Source Code


//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);
            }
        }
    }
}

Related

  1. cleanUp(boolean isDeleteOriginalFiles, Path[] filesToZip)
  2. clearAndDeleteDirecotry(Path path)
  3. createDeleteOnExitFile(Path path)
  4. delete(@Nullable Path path)
  5. delete(final String[] paths)
  6. delete(Path path)
  7. delete(Path path)
  8. delete(Path path)