Stay organized with collections
Save and categorize content based on your preferences.
FilenameFilter
@FunctionalInterface interface FilenameFilter
Instances of classes that implement this interface are used to filter filenames. These instances are used to filter directory listings in the list
method of class File
, and by the Abstract Window Toolkit's file dialog component.
Summary
Public methods |
abstract Boolean |
Tests if a specified file should be included in a file list.
|
Public methods
accept
abstract fun accept(
dir: File!,
name: String!
): Boolean
Tests if a specified file should be included in a file list.
Parameters |
dir |
File!: the directory in which the file was found. |
name |
String!: the name of the file. |
Return |
Boolean |
true if and only if the name should be included in the file list; false otherwise. |
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,["# FilenameFilter\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFilenameFilter\n==============\n\n```\n@FunctionalInterface interface FilenameFilter\n```\n\n|-----------------------------|\n| [java.io.FilenameFilter](#) |\n\nInstances of classes that implement this interface are used to filter filenames. These instances are used to filter directory listings in the `list` method of class `File`, and by the Abstract Window Toolkit's file dialog component.\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.io.File,%20kotlin.String))`(`dir:` `[File](/reference/kotlin/java/io/File)!`, `name:` `[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!`)` Tests if a specified file should be included in a file list. |\n\nPublic methods\n--------------\n\n### accept\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun accept(\n dir: File!, \n name: String!\n): Boolean\n```\n\nTests if a specified file should be included in a file list.\n\n| Parameters ||\n|--------|----------------------------------------------------------------------------------------------------------|\n| `dir` | [File](/reference/kotlin/java/io/File)!: the directory in which the file was found. |\n| `name` | [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)!: the name of the file. |\n\n| Return ||\n|------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|\n| [Boolean](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html) | `true` if and only if the name should be included in the file list; `false` otherwise. |"]]