I need to load all files that matches the path or regular expression.
If the path is
"C:\Users\me\Desktop\project\src\test\resources\screenshots/*/*.png"
it should find all screenshots in "screenshots" folder. If the path is
C:\Users\me\Desktop\project\src\test\resources\screenshots/first.png
it should find only the one file.
I was trying to list all files that match the criteria using:
File dir = new File("/");
FileFilter fileFilter = new WildcardFileFilter(absolutePath);
File[] files = dir.listFiles(fileFilter);
but this is not recursive and finds files only in home folder.
I tried to also use Spring way:
ClassLoader cl = this.getClass().getClassLoader();
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
return resolver.getResources(pattern);
But this expects only relative paths and looking for files in classpath.
What is the correct, standard and pretty way how to do this?