Java File Path Delete deleteAllFiles(String directory)

Here you can find the source of deleteAllFiles(String directory)

Description

delete All Files

License

Open Source License

Declaration

public static boolean deleteAllFiles(String directory) 

Method Source Code

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

import java.io.*;

public class Main {
    public static boolean deleteAllFiles(String directory) {
        File file = new File(directory);
        if (file.isDirectory() && file.exists()) {
            String[] files = file.list();
            boolean flag = true;
            String[] arr$ = files;
            int len$ = files.length;

            for (int i$ = 0; i$ < len$; ++i$) {
                String item = arr$[i$];
                File tmpFile = new File(directory + File.separator + item);
                if (tmpFile.exists()) {
                    flag = flag && tmpFile.delete();
                }//from w  w w  .j  a va 2s .  c o m
            }

            return flag;
        } else {
            return true;
        }
    }
}

Related

  1. deleteAllFiles()
  2. deleteAllFiles(File dir)
  3. deleteAllFiles(File directory)
  4. deleteAllFiles(File directory)
  5. deleteAllFiles(File dirOrFile)
  6. deleteAllFiles(String folder, String type)
  7. deleteAllFiles(Vector filesToDelete)
  8. deleteAllFilesAux(String input, File swapFolder)
  9. deleteAllFilesIn(String dir)