Java Delete Temp Directory deleteTempDirectories(List lstTempDirectories)

Here you can find the source of deleteTempDirectories(List lstTempDirectories)

Description

delete Temp Directories

License

Apache License

Declaration

public static void deleteTempDirectories(List<String> lstTempDirectories) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.util.List;

public class Main {
    public static void deleteTempDirectories(List<String> lstTempDirectories) {
        // TODO Auto-generated method stub
        for (String file : lstTempDirectories) {
            System.out.println("Need to delete dir: " + file);
            deleteDir(new File(file));
        }/*  ww  w .  j  a  v a2 s  .c  om*/
    }

    public static boolean deleteDir(File dir) {
        if (dir.isDirectory()) {
            String[] children = dir.list();
            for (int i = 0; i < children.length; i++) {
                boolean success = deleteDir(new File(dir, children[i]));
                if (!success) {
                    return false;
                }
            }
        }

        // The directory is now empty so delete it
        return dir.delete();
    }
}

Related

  1. deleteTempDir()
  2. deleteTempDir(File file)
  3. deleteTempDirectory(File dir)
  4. deleteTempMapset(String mapsetFolder)
  5. deleteTemporaryDirectory(String dir)
  6. deleteTestData()