For example, to retrieve and print all *.java files
in the current directory:
File dir = new File(".");
String[] files = dir.list( new SuffixFileFilter(".java") );
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
| Modifier and Type | Field and Description |
|---|---|
| private String[] | suffixes
The filename suffixes to search for |
| Access | Constructor and Description |
|---|---|
| public | SuffixFileFilter(String
the suffix to allow, must not be null suffix)Constructs a new Suffix file filter for a single extension. |
| public | SuffixFileFilter(String[]
the suffixes to allow, must not be null suffixes)Constructs a new Suffix file filter for an array of suffixs. |
| public | SuffixFileFilter(List<E>
the suffixes to allow, must not be null suffixes)Constructs a new Suffix file filter for a list of suffixes. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the filename ends with one of our suffixesthe File to check file)Overrides org. Implements org. |
| public boolean | Returns: true if the filename ends with one of our suffixesthe File directory file, String the filename name)Overrides org. Implements org. |
| suffixes | back to summary |
|---|---|
| private String[] suffixes The filename suffixes to search for | |
| SuffixFileFilter | back to summary |
|---|---|
| public SuffixFileFilter(String suffix) Constructs a new Suffix file filter for a single extension.
| |
| SuffixFileFilter | back to summary |
|---|---|
| public SuffixFileFilter(String[] suffixes) Constructs a new Suffix file filter for an array of suffixs. The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
| |
| SuffixFileFilter | back to summary |
|---|---|
| public SuffixFileFilter(List<E> suffixes) Constructs a new Suffix file filter for a list of suffixes.
| |
| accept | back to summary |
|---|---|
| public boolean accept(File file) Overrides org. Implements org. Checks to see if the filename ends with the suffix.
| |
| accept | back to summary |
|---|---|
| public boolean accept(File file, String name) Overrides org. Implements org. Checks to see if the filename ends with the suffix. | |