Deprecated
Use WilcardFileFilter. Deprecated as this class performs directory filtering which it shouldn't do, but that can't be removed due to compatability.
This filter selects files, but not directories, based on one or more wildcards and using case-sensitive comparison.
The wildcard matcher uses the characters '?' and '*' to represent a
single or multiple wildcard characters.
This is the same as often found on Dos/Unix command lines.
The extension check is case-sensitive.
See FilenameUtils#wildcardMatch for more information.
For example:
File dir = new File(".");
FileFilter fileFilter = new WildcardFilter("*test*.java~*~");
File[] files = dir.listFiles(fileFilter);
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
}
| Modifier and Type | Field and Description |
|---|---|
| private String[] | wildcards
The wildcards that will be used to match filenames. |
| Access | Constructor and Description |
|---|---|
| public | WildcardFilter(String
the wildcard to match wildcard)Construct a new case-sensitive wildcard filter for a single wildcard. |
| public | WildcardFilter(String[]
the array of wildcards to match wildcards)Construct a new case-sensitive wildcard filter for an array of wildcards. |
| public | WildcardFilter(List<E>
the list of wildcards to match wildcards)Construct a new case-sensitive wildcard filter for a list of wildcards. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the filename matches one of the wildcardsthe file directory dir, String the filename name)Overrides org. Implements org. |
| public boolean | Returns: true if the filename matches one of the wildcardsthe file to check file)Overrides org. Implements org. |
| wildcards | back to summary |
|---|---|
| private String[] wildcards The wildcards that will be used to match filenames. | |
| WildcardFilter | back to summary |
|---|---|
| public WildcardFilter(String wildcard) Construct a new case-sensitive wildcard filter for a single wildcard.
| |
| WildcardFilter | back to summary |
|---|---|
| public WildcardFilter(String[] wildcards) Construct a new case-sensitive wildcard filter for an array of wildcards.
| |
| WildcardFilter | back to summary |
|---|---|
| public WildcardFilter(List<E> wildcards) Construct a new case-sensitive wildcard filter for a list of wildcards.
| |
| accept | back to summary |
|---|---|
| public boolean accept(File dir, String name) Overrides org. Implements org. Checks to see if the filename matches one of the wildcards. | |
| accept | back to summary |
|---|---|
| public boolean accept(File file) Overrides org. Implements org. Checks to see if the filename matches one of the wildcards.
| |