Here you can find the source of deleteEmptyParents(File currentParentFile, String inputDir)
public static void deleteEmptyParents(File currentParentFile, String inputDir)
//package com.java2s; //License from project: Open Source License import java.io.File; public class Main { public static void deleteEmptyParents(File currentParentFile, String inputDir) { if (currentParentFile != null && !currentParentFile.getAbsolutePath().equals(inputDir) && (currentParentFile.listFiles() == null || currentParentFile.listFiles().length == 0)) { File nextParent = currentParentFile.getParentFile(); if (currentParentFile.delete()) { deleteEmptyParents(nextParent, inputDir); }//w w w .j a v a 2 s. c om } } }