Here you can find the source of deleteDirectory(File path)
Parameter | Description |
---|---|
path | File or Directory to delete. |
static public boolean deleteDirectory(File path)
//package com.java2s; //License from project: LGPL import java.io.File; public class Main { /**//ww w . j a v a2 s . co m * Tries to delete a directory and all contained files and subdirectories * * @param path * File or Directory to delete. * @return returns true if the directory could be deleted. Also return true * if the directory did not exist from the start. */ static public boolean deleteDirectory(File path) { if (!path.exists()) { return true; } 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(); } } } return (path.delete()); } }