Here you can find the source of deleteFolder(File dir, boolean deleteFolderItself)
Parameter | Description |
---|---|
dir | a parameter |
deleteFolderItself | a parameter |
public static void deleteFolder(File dir, boolean deleteFolderItself)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**//w ww . j a v a 2 s.c o m * Deletes given folder with all of its content * * @param dir * @param deleteFolderItself */ public static void deleteFolder(File dir, boolean deleteFolderItself) { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isDirectory()) { deleteFolder(f, true); } else if (f.isFile()) { if (!f.delete()) { System.err.println("Cannot delete file " + f.getAbsolutePath()); } } } if (deleteFolderItself) { if (!dir.delete()) { System.err.println("Cannot delete folder " + dir.getAbsolutePath()); } } } }