Apache Commons IO to delete directory using FileUtils

Tags: Apache Commons IO

Java Code Examples for using deleteDirectory() method of org.apache.commons.io.FileUtils class

package simplesolution.dev;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;

public class FileUtilsDeleteDirectoryExample {

    public static void main(String... args) {
        try {
            File directoryToDelete = new File("D:\\Data\\test");
            FileUtils.deleteDirectory(directoryToDelete);
        }catch(IOException ex) {
            ex.printStackTrace();
        }
    }
}

Happy Coding 😊