Open mausan-IT opened 3 years ago
You can either specify a searchPattern
on the Directory.list(Class informationClass, String searchPattern)
, which ensures that the filtering is done server side. Or you just call Directory.list()
and need to do the filtering client side using a for loop over the results.
From the JavaDoc:
* Two wild card characters are supported in the search pattern. The "?" (question mark) character matches a single
* character. If a search pattern contains one or more "?" characters, then exactly that number of characters is
* matched by the wildcards. For example, the criterion "??x" matches "abx" but not "abcx" or "ax", because the two
* file names do not have enough characters preceding the literal. When a file name criterion has "?" characters
* trailing a literal, then the match is made with specified number of characters or less. For example, the
* criterion "x??" matches "xab", "xa", and "x", but not "xabc". If only "?" characters are present in the file name
* selection criterion, then the match is made as if the criterion contained "?" characters trailing a literal.
* The "*" (asterisk) character matches an entire file name. A null or empty specification criterion also selects
* all file names. For example, "*.abc" or ".abc" match any file with an extension of "abc". "*.*", "*", or empty
* string("") match all files in a directory.
Does this answer your question @mausan-IT
You can either specify a
searchPattern
on theDirectory.list(Class informationClass, String searchPattern)
, which ensures that the filtering is done server side. Or you just callDirectory.list()
and need to do the filtering client side using a for loop over the results.From the JavaDoc:
* Two wild card characters are supported in the search pattern. The "?" (question mark) character matches a single * character. If a search pattern contains one or more "?" characters, then exactly that number of characters is * matched by the wildcards. For example, the criterion "??x" matches "abx" but not "abcx" or "ax", because the two * file names do not have enough characters preceding the literal. When a file name criterion has "?" characters * trailing a literal, then the match is made with specified number of characters or less. For example, the * criterion "x??" matches "xab", "xa", and "x", but not "xabc". If only "?" characters are present in the file name * selection criterion, then the match is made as if the criterion contained "?" characters trailing a literal. * The "*" (asterisk) character matches an entire file name. A null or empty specification criterion also selects * all file names. For example, "*.abc" or ".abc" match any file with an extension of "abc". "*.*", "*", or empty * string("") match all files in a directory.
hello , if I want to get the files with createTime < LocalDate.now().atStartOfDay , could the searchPattern work? From the doc , I couldn't see it
Hi,
No, the searchPattern is based on name only. There is no way to do server-side filtering on creation or modification times. This will need to happen client-side.
Hello
I working with a remote directory. In my first approche, used JCIFS and filter files by name with implementation of SmbFilenameFilter.
Now I need to do the same operation with SBMJ. There is an equivalent class in SBMJ? How I can do that?
My original Code:
static class TxsFilenameFilter implements SmbFilenameFilter {