Stay organized with collections
Save and categorize content based on your preferences.
Filter
@FunctionalInterface interface Filter<T : Any!>
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.
Summary
Public methods |
abstract Boolean |
Decides if the given directory entry should be accepted or filtered.
|
Public methods
accept
abstract fun accept(entry: T): Boolean
Decides if the given directory entry should be accepted or filtered.
Parameters |
entry |
T: the directory entry to be tested |
Return |
Boolean |
true if the directory entry should be accepted |
Exceptions |
java.io.IOException |
If an I/O error occurs |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# DirectoryStream.Filter\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFilter\n======\n\n```\n@FunctionalInterface interface Filter\u003cT : Any!\u003e\n```\n\n|-------------------------------------------|\n| [java.nio.file.DirectoryStream.Filter](#) |\n\nAn 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)](/reference/kotlin/java/nio/file/Files#newDirectoryStream(java.nio.file.Path,%20java.nio.file.DirectoryStream.Filter)) method when opening a directory to iterate over the entries in the directory.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | [accept](#accept(java.nio.file.DirectoryStream.Filter.T))`(`entry:` `T`)` Decides if the given directory entry should be accepted or filtered. |\n\nPublic methods\n--------------\n\n### accept\n\nAdded in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun accept(entry: T): Boolean\n```\n\nDecides if the given directory entry should be accepted or filtered.\n\n| Parameters ||\n|---------|-------------------------------------|\n| `entry` | T: the directory entry to be tested |\n\n| Return ||\n|------------------------------------------------------------------------------------|--------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if the directory entry should be accepted |\n\n| Exceptions ||\n|-----------------------|------------------------|\n| `java.io.IOException` | If an I/O error occurs |"]]