String filenames = file.list( someFilter );will get list of files in this directory. Wildcards won’t work. Note it returns an array of Strings, not including the directory, not File objects. Files are not in any particular order. They include the subdirectories, but not the . or .. entries.
Your FilenameFilter needs at a minimum to filter with File.isDirectory().
You can also use FileDialog.setFilenameFilter( java.io.FilenameFilter ) to restrict which files are displayed in a File choosing dialog.
Here is how to write a simple class that implements the FilenameFilter interface:I have written 10 FilenameFilters with source. All are trivial except for the MultiFilter that lets you combine other filters in various ways.
They come with Java source. The collection is mainly for newbies trying to get some ideas on how FilenameFilters work and how you could write them.
|AllDirectoriesFilter||gets all directories|
|AllFilesFilter||gets all files|
|DirListFilter||gets a list of directories|
|EndsWithFilter||gets files whose names end with a given string.|
|ExtensionFilter||gets files matching a list of extensions|
|FileLengthFilter||gets short or long files|
|FilenameLengthFilter||gets short or long filenames|
|FileListFilter||gets a list of files|
|MultiFilter||combines other Filters with consider, must and never.|
|RecentFilter||filters based on lastModified date|
|RegexFilter||filters with Regex expressions.|
|StartsWithFilter||gets files whose names start with a given string.|
You can cascade (combine) FilenameFilters by having one ask advice of another, or write a mother filter that asks the advice of several child filters and && or || the results of their accept methods. MultiFilter makes that task easy.
This page is posted
Optional Replicator mirror
Your face IP:[220.127.116.11]
You are visitor number|