SearchFilesByFullNameRegex - ViiSE/papka GitHub Wiki

SearchFilesByFullNameRegex

SearchFilesByFullNameRegex - search files in folder by file full name.

Constructors

public SearchFilesByFullNameRegex(Folder<File> folder, boolean includeChildren)


Folder<File> folder - being searched;
boolean includeChildren - to do a full depth-first search, include all children (default - false)?
public SearchFilesByFullNameRegex(Folder<File> folder)


Folder<File> folder - being searched.

Example

List<File> files = new ArrayList<>();
files.add("/home/doc1/doc1_file1.png");
files.add("/home/doc1/doc1_file2.pdf");
files.add("/home/doc1/folder1/folder1_file1.png");
files.add("/home/doc1/folder2/folder2_file1.pdf");
files.add("/home/doc2/file1.txt");

Folder<File> folder = new FolderFile(
        "/home/file1.txt",
        "/home/file2.pdf",
        "/home/file3.txt",
        "/home/folder1/f1_file1.pdf",
        "/home/folder1/f1_file2.pdf"
);

boolean includeChildren = true;
Search<List<File>, String> search = new SearchFilesByFullNameRegex<>(folder, includeChildren);
List<File> files = search.answer("([^.]*)(.pdf$)");
files.forEach(file -> System.out.println(file.getName()));
Output:

file2.pdf
f1_file1.pdf
f1_file2.pdf
folder1_file1.png
folder2_file1.pdf

Links

Search - implementable interface.

⚠️ **GitHub.com Fallback** ⚠️