added list_files, fixes #589
This commit is contained in:
1 parent
5a15c115ac
commit
6e5af5bfc8
8 files changed
+126
-74
No files matched your search
@@ -23,6 +23,7 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FileModule extends Module
|
||||
{
|
||||
@@ -175,4 +176,18 @@ public class FileModule extends Module
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Stream<Path> listFiles(Path dir, String ext)
|
||||
{
|
||||
boolean folderListing = ext.equals("folder");
|
||||
try
|
||||
{
|
||||
return Files.list(dir).
|
||||
filter(path -> folderListing?Files.isDirectory(path):path.toString().endsWith(ext));
|
||||
}
|
||||
catch (IOException ignored)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user