Home > Contents > Index >
Utilities.directoryList
Returns a vector of file names in a given directory that satisfy a specified filter pattern.
Syntax
public static Vector directoryList(String path, String filter, boolean recurse, int maxcount)Parameters
path
- Path name of the directory to search.
filter
- File filter, that typically includes wildcards. The two wildcards supported are:
- *, which matches any string (or no string).
- ?, which matches any single character.
For example, the filter
"*.bat"
would match any file ending in the suffix.bat
. The filter"???"
would match any file whose name contains exactly three characters. Settingfilter
tonull
tellsdirectoryList
to match all files in the specified path.
recurse
- A
true
value tells the method to look for matching files (based on the filter) in the subdirectories of the supplied path. Afalse
value tells the method to restrict the search to the directory specify in path.
maxcount
- Specifies the maximum number of files that will be returned in the vector. It is possible, though rare, to generate
outofmemory
exceptions by specifying a very large number.
Description
The
directoryList
method returns a vector of file names in a given directory that satisfy a specified filter pattern. Both the directory path and the filter are converted usingosSafeSpec()
.Returns
Returns the vector of file names in the path that match the filter.
Example
The following code finds all the Java source code files in directory
/users/bob
and all its subdirectories. Only the first 100 matching files will be returned:String Directory = "/users/bob"; String Filter = "*.java"; boolean Recurse = true; int Maxcount = 100; Vector JavaSourceFiles = Utilities.directoryList(Directory, Filter, Recurse, Maxcount); errNum = cs.GetErrno();See Also
Home > Contents > Index > ![]()
Oracle JAVA Reference
Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.