Here you can find the source of deleteFolder(String path)
Parameter | Description |
---|---|
path | a parameter |
public static int deleteFolder(String path)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { /**/* w ww . ja va 2s . co m*/ * deleteFolder * * @param path * @return */ public static int deleteFolder(String path) { int res = 1; File dir = new File(path); String[] files = dir.list(); if (files != null && files.length > 0) { for (int i = 0; i < files.length; i++) { File temp = new File(path + "/" + files[i]); if (temp.isDirectory()) { res += deleteFolder(temp.getAbsolutePath()); } try { temp.delete(); } catch (Exception ee) { return -1; } } } dir.delete(); return res; } }