Reputation: 1021
interface FilenameFilter {
boolean accept(File dir, String name);
}
As Far as I know FileNameFilter is used to select files based on specific pattern or extension. For that 'String name' alone is enough. Why the 'File dir' parameter is required? Is there any specific reason or use for that?
Upvotes: 1
Views: 497
Reputation: 5638
The dir object is the parent directory of the file, and name is the name of the file.
public boolean accept(File dir,
String name)
Checks to see if the File should be accepted by this filter.
Specified by:
accept in interface FilenameFilter
Specified by: accept in interface IOFileFilter
Parameters:
dir
- the directory File to check
name
- the filename within the directory to check
Returns:
true if this file matches the test
Upvotes: 2
Reputation: 12843
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.
Upvotes: 0
Reputation: 5657
FilenameFilter
- just interface.
You can write your own implementation that will be care about dir
where file placed
Upvotes: 1