[FEATURE] Added Directories#listFilesWithExtension

This commit is contained in:
JKetelaar
2016-01-09 19:32:52 +01:00
parent b9d79cd661
commit a6ad52824e
2 changed files with 22 additions and 1 deletions
@@ -304,4 +304,23 @@ public class Directories {
Core.verbose("File is deleted : " + file.getAbsolutePath());
}
}
/**
* Returns an array of files with from a given directory and a given extension
*
* @param directory The directory where should be searched
* @param extension The extension to be searched for, including the dot (like .json)
* @return An array of of files that match the request
*/
private File[] listFilesWithExtension(File directory, final String extension){
return directory.listFiles(new FilenameFilter() {
public boolean accept(File dir, String filename) {
return filename.endsWith(extension);
}
});
}
private File[] listJSONFiles(File directory) {
return listFilesWithExtension(directory, ".json");
}
}
@@ -1,5 +1,7 @@
package org.parabot.core.parsers.servers;
import java.io.File;
import java.io.FilenameFilter;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -64,7 +66,7 @@ public class LocalServers extends ServerParser {
}
}
// for ()
}
}