Java Delete Directory deleteDirectory(File file)

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

Description

delete Directory

License

Open Source License

Declaration

public static boolean deleteDirectory(File file) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    public static boolean deleteDirectory(File file) {
        File[] list = file.listFiles();
        boolean done = true;
        for (File f : list) {
            done &= deleteFile(f);//  ww w .ja  v  a  2 s  .  c o  m
        }
        return done;
    }

    public static boolean deleteDirectory(String file) {
        return deleteDirectory(new File(file));
    }

    public static boolean deleteFile(File file) {
        if (file.isDirectory()) {
            return deleteDirectory(file);
        } else {
            return file.delete();
        }
    }

    public static boolean deleteFile(String file) {
        return deleteFile(new File(file));
    }
}

Related

  1. deleteDirectory(File file)
  2. deleteDirectory(File file)
  3. deleteDirectory(File file)
  4. deleteDirectory(File file)
  5. deleteDirectory(File file)
  6. deleteDirectory(File file)
  7. deleteDirectory(File fileOrDir)
  8. deleteDirectory(File root)
  9. deleteDirectory(File root)