Stay organized with collections
Save and categorize content based on your preferences.
FilenameFilter
public
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
|
accept(File dir, String name)
Tests if a specified file should be included in a file list.
|
Public methods
accept
public abstract boolean accept (File dir,
String name)
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. |
Returns |
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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\nFilenameFilter\n==============\n\n\n`\npublic\n\n\ninterface\nFilenameFilter\n`\n\n\n`\n\n\n`\n\n|------------------------|\n| java.io.FilenameFilter |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nInstances of classes that implement this interface are used to\nfilter filenames. These instances are used to filter directory\nlistings in the `list` method of class\n`File`, and by the Abstract Window Toolkit's file\ndialog component. \n**See also:**\n\n- [File](/reference/java/io/File)\n- [File.list(java.io.FilenameFilter)](/reference/java/io/File#list(java.io.FilenameFilter))\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[accept](/reference/java/io/FilenameFilter#accept(java.io.File,%20java.lang.String))`(`[File](/reference/java/io/File)` dir, `[String](/reference/java/lang/String)` name) ` 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](/guide/topics/manifest/uses-sdk-element#ApiLevels) \n\n```\npublic abstract boolean accept (File dir, \n String name)\n```\n\nTests if a specified file should be included in a file list.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-----------------------------------------------------------|\n| `dir` | `File`: the directory in which the file was found. \u003cbr /\u003e |\n| `name` | `String`: the name of the file. \u003cbr /\u003e |\n\n| Returns ||\n|-----------|-----------------------------------------------------------------------------------------------|\n| `boolean` | `true` if and only if the name should be included in the file list; `false` otherwise. \u003cbr /\u003e |"]]