delete Directory - Java File Path IO

Java examples for File Path IO:Directory Delete

Description

delete Directory

Demo Code


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

public class Main {

    public static boolean deleteDirectory(File path) {
        if (path.exists()) {
            File[] files = path.listFiles();
            for (int i = 0; i < files.length; i++) {
                if (files[i].isDirectory()) {
                    deleteDirectory(files[i]);
                } else {
                    files[i].delete();//w w w.java2  s  .  com
                }
            }
        }
        return (path.delete());
    }
}

Related Tutorials