Currently I have the code like below:
public boolean accept(File dir, String filename) {
...
return filename.contains(".png") || filename.contains(".jpg") || file.isDirectory();
(the full code can be found there - https://stackoverflow.com/a/18523047/604388)
So, .png
and .jpg
are hardcoded now. I would like to make it as function parameter(s) and allow to pass several extensions, not just one. How could I do it?
I think I can pass list of extensions as array, but how could I perform all these checks (filename.contains()
) for all array elements?