Java Directory Delete nio deleteDirectory(String path)

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

Description

delete Directory

License

Open Source License

Declaration

public static void deleteDirectory(String path) throws NoSuchFileException, IOException 

Method Source Code

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

import java.io.File;

import java.io.IOException;

import java.nio.file.NoSuchFileException;

public class Main {
    public static void deleteDirectory(String path) throws NoSuchFileException, IOException {
        File file = new File(path);
        File[] contents = file.listFiles();
        if (contents != null) {
            for (File f : contents) {
                f.delete();/*from   ww w.j  a  v  a 2  s .c  o  m*/
            }
        }
        file.delete();
    }
}

Related

  1. deleteDirectory(Path directory)
  2. deleteDirectory(Path directory)
  3. deleteDirectory(Path directory)
  4. deleteDirectory(Path dirToDelete)
  5. deleteDirectory(Path path)
  6. deleteDirectoryAndContents(String dir)
  7. deleteDirectoryRecursively(Path dir)
  8. deleteDirectoryRecursively(Path path)
  9. deleteDirectorySelectively(Path path, Predicate predicate)