Java File Path Delete deleteAllFilesIn(String dir)

Here you can find the source of deleteAllFilesIn(String dir)

Description

delete All Files In

License

Apache License

Declaration

public static void deleteAllFilesIn(String dir) 

Method Source Code


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

import java.io.File;

import java.util.LinkedList;
import java.util.List;

public class Main {
    public static void deleteAllFilesIn(String dir) {
        List<File> files = getAllFilesIn(dir);
        for (int i = 0; i < files.size(); i++) {
            files.get(i).delete();/*from  ww  w. java2 s .  c o  m*/
        }
    }

    public static List<File> getAllFilesIn(String dir) {
        File file = new File(dir);
        File[] entities = file.listFiles();
        List<File> files = new LinkedList<File>();
        for (int i = 0; i < entities.length; i++) {
            File f = entities[i];
            if (f.isFile()) {
                files.add(f);
            }
        }
        return files;
    }
}

Related

  1. deleteAllFiles(File dirOrFile)
  2. deleteAllFiles(String directory)
  3. deleteAllFiles(String folder, String type)
  4. deleteAllFiles(Vector filesToDelete)
  5. deleteAllFilesAux(String input, File swapFolder)
  6. deleteAllFilesInDir(File dir)
  7. deleteAllFilesInDirectory(String path)
  8. deleteAllFilesOnlyInDirectory(File startingDir)
  9. deleteAllFilesRecursively(String directoryName)