wildcard - Efficient file system pattern matching in Java

  •        0

The `glob` method collects files and directories using literal characters and optional wildcards: Paths paths = new Paths(); paths.glob("/some/directory", "resources"); paths.glob("/some/directory", "images/**/*.jpg", "!**/.svn/**");The first parameter defines the root directory of the search. Subsequent parameters are a variable number of search patterns. The following wildcards are supported in search patterns:

`?`Matches any single character. Eg, `something?` collects any path that is named "something" plus any character.
`**`Matches any characters up to the next slash. Eg, `**/**/something**` collects any path that has two directories, then a file or directory that starts with the name "something".
`**`Matches any characters. Eg, `**/something/**` collects any path that contains a directory named "something".
!A pattern starting with an exclamation point (!) causes paths matched by the pattern to be excluded, even if other patterns would select the paths.
When using `glob`, the search is done as efficiently as possible. Directories are not traversed if none of the search patterns can match them.Glob is also used when constructor parameters are specified: Paths paths = new Paths("/some/directory", "resources");




comments powered by Disqus

Related Projects