vxh.viet
4/8/2016 - 4:09 AM

How to delete a whole folder and content?

How to delete a whole folder and content?

Source: StackOverflow

Question: How to delete a whole folder and content?

Answer: You can delete files and folders recursively like this:

void deleteRecursive(File fileOrDirectory) {
    if (fileOrDirectory.isDirectory())
        for (File child : fileOrDirectory.listFiles())
            deleteRecursive(child);

    fileOrDirectory.delete();
}