Here you can find the source of recursivelyDeleteEmptyDirectories(File fileToDelete)
public static void recursivelyDeleteEmptyDirectories(File fileToDelete)
//package com.java2s; //License from project: LGPL import java.io.*; public class Main { public static void recursivelyDeleteEmptyDirectories(File fileToDelete) { if (fileToDelete.isDirectory()) { for (File subFile : fileToDelete.listFiles()) { recursivelyDeleteEmptyDirectories(subFile); }// w w w .j av a2 s . c o m if (fileToDelete.listFiles().length == 0) { fileToDelete.delete(); } } } }