Here you can find the source of deleteRecursively(File[] roots)
Parameter | Description |
---|---|
roots | the roots |
public static boolean deleteRecursively(File[] roots)
//package com.java2s; import java.io.File; public class Main { /**/*from w w w . ja v a 2 s.co m*/ * Delete recursively. * * @param roots the roots * @return true, if successful */ public static boolean deleteRecursively(File[] roots) { boolean deleted = true; for (File root : roots) { deleted &= deleteRecursively(root); } return deleted; } /** * Delete recursively. * * @param root the root * @return true, if successful */ public static boolean deleteRecursively(File root) { return deleteRecursively(root, true); } /** * Delete recursively. * * @param root the root * @param deleteRoot the delete root * @return true, if successful */ public static boolean deleteRecursively(File root, boolean deleteRoot) { if (root != null && root.exists()) { if (root.isDirectory()) { File[] children = root.listFiles(); if (children != null) { for (File aChildren : children) { innerDeleteRecursively(aChildren); } } } if (deleteRoot) { return root.delete(); } else { return true; } } return false; } /** * Inner delete recursively. * * @param root the root * @return true, if successful */ private static boolean innerDeleteRecursively(File root) { return deleteRecursively(root, true); } }