How to filter resource files based on wild card using only JAVA APIs -
There are several processing files located in the Meta-INF folder in my spring project. I use wild card based on file name I want to filter those files
Example: Files are in the Meta-INF folder as follows
a-config.xml b-config .xml c-config.xml < / Code> What do I need to filter these files using wildcard * - config.xml
I already know that i I can easily use the spring ResourcePatternResolver for this I tried to use the java.io.filefilter , but for this I have to pass a RegEx to filter the file names. Example:
fileFilter customFilter = new FileFilter () {@Override accepts public boolean (file pathname) {if (pathname.getName (). Matches ("(. *) Config (. *) ")) {Return true; } return false; }}; Is there any other way of doing this without using third party dependencies (Spring, Google Guava etc.) and using Regx? I want to use ordinary wild card characters for filtering. Your comments are highly appreciated.
What you want is a low-expression pattern matching Applying your own globbing using a solution string class method (like opensWith , ends , ...) is. But I think using regex is the best and common solution.
Comments
Post a Comment