Java Delete File Recursively deleteRecursiveDirectories(String mainDir)

Here you can find the source of deleteRecursiveDirectories(String mainDir)

Description

delete Recursive Directories

License

Open Source License

Declaration

public static void deleteRecursiveDirectories(String mainDir) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static void deleteRecursiveDirectories(String mainDir) {
        File dir = new File(mainDir);
        File subDir1 = new File(dir.getAbsolutePath() + "\\subdir1");
        File subDir2 = new File(dir.getAbsolutePath() + "\\subdir2");
        File tempFile1 = new File(dir.getAbsolutePath() + "\\file1.txt");
        File tempFile2 = new File(subDir1.getAbsolutePath() + "\\file2.txt");
        tempFile1.delete();/*from ww w  .  ja  v a2  s  .c o m*/
        tempFile2.delete();
        subDir1.delete();
        subDir2.delete();
        dir.delete();
    }
}

Related

  1. deleteRecursive(final File file)
  2. deleteRecursive(final File file)
  3. deleteRecursive(final File file)
  4. deleteRecursive(final File file, final boolean collect)
  5. deleteRecursiveDir(File directory)
  6. deleteRecursiveDirectory(String dirName)
  7. deleteRecursiveFileDir(File dir)
  8. deleteRecursively(File dir)
  9. deleteRecursively(File directory)