DirectoryStream.Filter
Stay organized with collections
Save and categorize content based on your preferences.
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.
Public Method Summary
abstract
boolean
|
accept(T entry)
Decides if the given directory entry should be accepted or filtered.
|
Public Methods
public
abstract
boolean
accept
(T entry)
Decides if the given directory entry should be accepted or filtered.
Parameters
entry |
the directory entry to be tested |
Returns
true
if the directory entry should be accepted
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["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."],[[["`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."]]],["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"]]