I'm loading resources from the file system as follows using wildcards:
Resource[] resources = new PathMatchingResourcePatternResolver()
.getResources("/my/path/*.zip");
Question: how can I load only .zip files that NOT have an underscore _ in the filename?
Is that possible using the wildcard patterns at all?
PathMatchingResourcePatternResolver will use the AntPathMatcher by default, which (luckily) can do RegExp based wildcards, so you can use it like this:
Resource[] resources = new PathMatchingResourcePatternResolver()
.getResources("/my/path/{filename:[^_]*.zip}");
[^_] - is a negated character range, which will match any character except for _, so [^_]*.zip will, in turn, match any filenames that end with .zip and do not have _ in their name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With