// we always allow directories, regardless of their extension
if (f.isDirectory()) { return true; }
// ok, it's a regular file so check the extension
String name = f.getName().toLowerCase();
for (int i = extensions.length - 1; i >= 0; i--) {
if (name.endsWith(extensions[i])) {
return true;
}
}
return false;