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