Here you can find the source of deleteEmptyFolders(String[] args)
public static void deleteEmptyFolders(String[] args)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.Stack; public class Main { static File base = new File( "D:/Thesis test results/thesisSimple/imageOutput/UB72"); public static void deleteEmptyFolders(String[] args) { Stack<File[]> dfs = new Stack<File[]>(); dfs.add(base.listFiles());/*from w w w .j av a2 s . co m*/ while (!dfs.isEmpty()) { File[] subFiles = dfs.pop(); if (subFiles == null) continue; for (File subFolder : subFiles) { if (!subFolder.isDirectory()) continue; try { subFolder.delete(); } catch (Exception e) { } ; dfs.add(subFolder.listFiles()); } } } }