Java Folder Delete emptyDerbyTestDirectory(final String derbyTestDirectory)

Here you can find the source of emptyDerbyTestDirectory(final String derbyTestDirectory)

Description

Clean out the test directory.

License

Apache License

Parameter

Parameter Description
derbyTestDirectory the root directory of a derby db.

Declaration

static public void emptyDerbyTestDirectory(final String derbyTestDirectory) 

Method Source Code

//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

import java.io.File;

public class Main {
    /**//from w  w w .ja va 2  s . c  o  m
     * Clean out the test directory. This is not fully recursive, since we don't want a run-away delete to wipe out all the contents of the disk by mistake.
     *
     * @param derbyTestDirectory the root directory of a derby db.
     */
    static public void emptyDerbyTestDirectory(final String derbyTestDirectory) {
        // Delete the files in the derbyTestDirectory directory.
        File tempDirectory = new File(derbyTestDirectory);
        File[] files = tempDirectory.listFiles();
        if (files != null) {
            for (File file : files) {
                if (file.isDirectory()) {
                    File[] subFiles = file.listFiles();
                    for (File subFile : subFiles) {
                        if (subFile.isDirectory()) {
                            File[] subSubFiles = subFile.listFiles();
                            for (File subSubFile : subSubFiles) {
                                subSubFile.delete();
                            }
                        }
                        subFile.delete();
                    }
                }
                file.delete();
            }
        }
    }
}

Related

  1. clearFolder(String folder)
  2. clearFolder(String path)
  3. clearFolderContent(String folderName)
  4. deepDelete(final File file)
  5. emptyAndDelete(File fileOrDir)
  6. emptyFile(final String urlFile)
  7. emptyFile(String srcFilename)
  8. emptyFolder(File dir)
  9. emptyFolder(File folder)