Java Delete Directory deleteDirectory(String name)

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

Description

delete Directory

License

Open Source License

Declaration

public static void deleteDirectory(String name) 

Method Source Code


//package com.java2s;

import java.io.File;

public class Main {
    public static void deleteDirectory(String name) {
        File folder = new File(name);
        if (folder.exists()) {
            File[] files = folder.listFiles();
            if (files != null) {
                for (File f : files) {
                    if (f.isDirectory()) {
                        deleteDirectory(f.getAbsolutePath());
                    } else {
                        f.delete();//ww  w .  j  av a 2s  .co  m
                    }
                }
            }
            folder.delete();
        }
    }
}

Related

  1. deleteDirectory(String dirName)
  2. deleteDirectory(String dirName)
  3. deleteDirectory(String dirname, boolean recursive)
  4. deleteDirectory(String fileName)
  5. deleteDirectory(String folder)
  6. deleteDirectoryContent(final String strDir)
  7. deleteDirectoryContents(File directory)
  8. deleteDirectoryContents(File directory)
  9. deleteDirectoryContents(File directory)