For example, to print all files and directories in the
current directory whose name is Test:
File dir = new File(".");
String[] files = dir.list( new NameFileFilter("Test") );
for ( int i = 0; i < files.length; i++ ) {
System.out.println(files[i]);
}
| Modifier and Type | Field and Description |
|---|---|
| private IOCase | caseSensitivity
Whether the comparison is case sensitive. |
| private String[] | names
The filenames to search for |
| Access | Constructor and Description |
|---|---|
| public | NameFileFilter(String
the name to allow, must not be null name)Constructs a new case-sensitive name file filter for a single name. |
| public | NameFileFilter(String
the name to allow, must not be null name, IOCase how to handle case sensitivity, null means case-sensitive caseSensitivity)Construct a new name file filter specifying case-sensitivity. |
| public | NameFileFilter(String[]
the names to allow, must not be null names)Constructs a new case-sensitive name file filter for an array of names. |
| public | NameFileFilter(String[]
the names to allow, must not be null names, IOCase how to handle case sensitivity, null means case-sensitive caseSensitivity)Constructs a new name file filter for an array of names specifying case-sensitivity. |
| public | NameFileFilter(List<E>
the names to allow, must not be null names)Constructs a new case-sensitive name file filter for a list of names. |
| public | NameFileFilter(List<E>
the names to allow, must not be null names, IOCase how to handle case sensitivity, null means case-sensitive caseSensitivity)Constructs a new name file filter for a list of names specifying case-sensitivity. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the filename matchesthe File to check file)Overrides org. Implements org. |
| public boolean | Returns: true if the filename matchesthe File directory file, String the filename name)Overrides org. Implements org. |
| caseSensitivity | back to summary |
|---|---|
| private IOCase caseSensitivity Whether the comparison is case sensitive. | |
| names | back to summary |
|---|---|
| private String[] names The filenames to search for | |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(String name) Constructs a new case-sensitive name file filter for a single name.
| |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(String name, IOCase caseSensitivity) Construct a new name file filter specifying case-sensitivity.
| |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(String[] names) Constructs a new case-sensitive name file filter for an array of names. The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
| |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(String[] names, IOCase caseSensitivity) Constructs a new name file filter for an array of names specifying case-sensitivity. The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
| |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(List<E> names) Constructs a new case-sensitive name file filter for a list of names.
| |
| NameFileFilter | back to summary |
|---|---|
| public NameFileFilter(List<E> names, IOCase caseSensitivity) Constructs a new name file filter for a list of names specifying case-sensitivity.
| |
| accept | back to summary |
|---|---|
| public boolean accept(File file) Overrides org. Implements org. Checks to see if the filename matches.
| |
| accept | back to summary |
|---|---|
| public boolean accept(File file, String name) Overrides org. Implements org. Checks to see if the filename matches. | |