Java Delete Temp Directory deleteTestDir(final File file)

Here you can find the source of deleteTestDir(final File file)

Description

delete Test Dir

License

Open Source License

Declaration

static void deleteTestDir(final File file) 

Method Source Code

//package com.java2s;
/*//w  w  w  . ja va  2s .c  o m
 * Copyright (c) 2016 Cisco Systems, Inc. and others.  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
 */

import java.io.File;

public class Main {
    static void deleteTestDir(final File file) {
        if (file.isDirectory()) {
            File[] filesToDelete = file.listFiles();
            if (filesToDelete != null) {
                for (File f : filesToDelete) {
                    deleteTestDir(f);
                }
            }
        }
        if (!file.delete()) {
            throw new RuntimeException("Failed to clean up after test");
        }
    }
}

Related

  1. deleteTempDirectories(List lstTempDirectories)
  2. deleteTempDirectory(File dir)
  3. deleteTempMapset(String mapsetFolder)
  4. deleteTemporaryDirectory(String dir)
  5. deleteTestData()
  6. deleteTestDirectory(File testDir)
  7. deleteTestFile(String fileName)
  8. deleteTestFiles()
  9. deleteTestFolder()