DirectoryStream.Filter
Stay organized with collections
Save and categorize content based on your preferences.
Page Summary
DirectoryStream.Filter is used to determine which directory entries are included when iterating through a directory.
Implement the accept method to define the filtering logic, returning true for entries to be included and throwing IOException for I/O errors.
public static interface
DirectoryStream.Filter
An interface that is implemented by objects that decide if a directory
entry should be accepted or filtered. A Filter is passed as the
parameter to the Files.newDirectoryStream(Path, DirectoryStream.Filter)
method when opening a directory to iterate over the entries in the
directory.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[],["The `DirectoryStream.Filter` interface determines if a directory entry is accepted or filtered. It's used with `Files.newDirectoryStream` to iterate through directory entries. The `accept(T entry)` method is crucial: it takes a directory entry as input and returns `true` if the entry should be accepted. An `IOException` can be thrown if an I/O error happens during the process. This is the key element to decide what directory entry should be included in the stream.\n"]]