FileSet Package / Class for Java

Can anyone suggest a FileSet package / class in Java. By FileSet, I mean a set of files and directories along with inclusion and exclusion rules with a regular expression (similar to Apache Ant). Thank.

+3
source share
2 answers

You can use File#listFiles()where you pass FileFilteror FilenameFilterwhere you can specify the desired template in the method accept().

eg.

File[] txtFiles = file.listFiles(new FilenameFilter() {
    @Override public boolean accept(File dir, String name) {
        return name.endsWith(".txt"); // You can use String#matches() as well.
    }
});
+1
source

Apache Commons IO FileUtils may be what you want. It has the ability to identify files with an additional filter for file names that you can implement yourself.

listFiles() iterateFiles() .

+2

Source: https://habr.com/ru/post/1746745/


All Articles