Here you can find the source of deleteEmptDir(String Path, String username)
Parameter | Description |
---|---|
Path | String |
username | String |
public static void deleteEmptDir(String Path, String username)
//package com.java2s; import java.io.File; import java.util.Vector; public class Main { /**//from www . j a v a 2s . c o m * This Method is responsible for deleting the author dir * in which permission given when it empty * @param Path String * @param username String */ public static void deleteEmptDir(String Path, String username) { String pathdir = Path + "/" + username; File fdir = new File(pathdir); Vector y = new Vector(); String ContentList[] = fdir.list(); for (int j = 0; j < ContentList.length; j++) { y.add(ContentList[j]); } if (y.size() == 0) deleteFile(fdir); } /** * This Method is responsible for deleting the file and dir * @param f File */ public static void deleteFile(File f) { int i = 0; if (f.isDirectory()) { File file[] = f.listFiles(); while (i < file.length) { deleteFile(file[i]); i++; } } f.delete(); } }