Here you can find the source of deleteEmptyParentFolders(File leafFolder)
Parameter | Description |
---|---|
leafFolder | the leaf folder |
public static void deleteEmptyParentFolders(File leafFolder)
//package com.java2s; /*********************************************************************************************************************** * Copyright (c) 2008 empolis GmbH and brox IT Solutions GmbH. All rights reserved. This program and the accompanying * materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html * * Contributors: Marius Cimpean (brox IT Solutions GmbH) - initial creator **********************************************************************************************************************/ import java.io.File; public class Main { /** Binary Storage Service configured root location */ private static File _root = null; /**/*from w w w . j av a2 s. c om*/ * Delete empty parent folders. * * @param leafFolder * the leaf folder */ public static void deleteEmptyParentFolders(File leafFolder) { while (leafFolder != null && !leafFolder.equals(_root)) { final String[] elements = leafFolder.list(); if (elements == null || elements.length > 0) { // folder does not exist anymore or is not empty. return; } leafFolder.delete(); leafFolder = leafFolder.getParentFile(); } } }