Java Path Delete nio deletePath(Path path)

Here you can find the source of deletePath(Path path)

Description

delete Path

License

Apache License

Declaration

public static void deletePath(Path path) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.nio.file.Path;

public class Main {
    public static void deletePath(Path path) {
        if (path == null) {
            return;
        }// ww w .  j  a  v  a  2s  .  com

        File file = path.toFile();
        if (file.isDirectory()) {
            for (File item : file.listFiles()) {
                deletePath(item.toPath());
            }
        }

        deleteFile(file);
    }

    public static void deleteFile(File file) {
        if (file == null || !file.exists()) {
            return;
        }
        file.delete();
    }
}

Related

  1. deleteIfExists(Path value)
  2. deleteIndexBeforeStart(String basePath)
  3. deleteLockFile(Path logFile)
  4. deleteNotEmptyDirectory(Path path)
  5. deleteOnExit(Path path)
  6. deletePathRecursively(String path)
  7. deleteQuietly(@Nullable Path path)
  8. deleteQuietly(Path dir)
  9. deleteRecursive(Path path)