Here you can find the source of deleteDir(File path)
Parameter | Description |
---|---|
path | path to delete |
Parameter | Description |
---|---|
IOException | if the delete fails |
public static void deleteDir(File path) throws IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; public class Main { /**//from ww w . ja v a2s . c o m * Recursively delete a directory and all the files it contains. * * @param path path to delete * @throws IOException if the delete fails */ public static void deleteDir(File path) throws IOException { try { if (path.isDirectory()) { File[] files = path.listFiles(); if (files != null) { for (int i = 0; i < files.length; i++) { deleteDir(files[i]); } } } path.delete(); } catch (Exception e) { e.printStackTrace(); } } }