Java Delete Temp Directory deleteTempDirectory(File dir)

Here you can find the source of deleteTempDirectory(File dir)

Description

delete Temp Directory

License

Open Source License

Declaration

static public void deleteTempDirectory(File dir) throws IOException 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    static public void deleteTempDirectory(File dir) throws IOException {
        deleteDirectoryContents(dir);/*from  ww w .ja va2  s  . c om*/

        boolean success = dir.delete();
        if (!success) {
            throw new IOException();
        }
    }

    static private void deleteDirectoryContents(File dir) throws IOException {
        File[] files = dir.listFiles();

        for (File file : files) {

            if (file.isDirectory()) {
                deleteDirectoryContents(file);
            }

            file.delete();
        }
    }
}

Related

  1. deleteTempDir()
  2. deleteTempDir(File file)
  3. deleteTempDirectories(List lstTempDirectories)
  4. deleteTempMapset(String mapsetFolder)
  5. deleteTemporaryDirectory(String dir)
  6. deleteTestData()
  7. deleteTestDir(final File file)