Here you can find the source of deleteRecursively(final File directory)
Parameter | Description |
---|---|
directory | a parameter |
public static boolean deleteRecursively(final File directory)
//package com.java2s; import java.io.File; public class Main { /**/* www .jav a2s .com*/ * Delete a directory recursively * * @param directory * @return whether it succeeded (see also {@link File#delete()}) */ public static boolean deleteRecursively(final File directory) { if (directory == null) { return true; } final File[] list = directory.listFiles(); if (list == null) { return true; } for (final File file : list) { if (file.isFile()) { if (!file.delete()) { return false; } } else if (file.isDirectory()) { if (!deleteRecursively(file)) { return false; } } } return directory.delete(); } }