SearchFilesByShortNameRegex - ViiSE/papka GitHub Wiki

SearchFilesByShortNameRegex

SearchFilesByShortNameRegex - search files in filesystem by file short name.

Constructors

public SearchFilesByShortNameRegex(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 SearchFilesByShortNameRegex(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 SearchFilesByShortNameRegex<>(folder, includeChildren);
List<File> files = search.answer("^doc1.*$)");
files.forEach(file -> System.out.println(file.getName()));
Output:

doc1_file1.png
doc1_file2.pdf

Links

Search - implementable interface.

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