Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- private static ArrayList<File> getAllImages(String basePath) {
- ArrayList<File> filesList = new ArrayList<File>();
- getAllFilesHelper(basePath, filesList);
- return filesList;
- }
- private static void getAllFilesHelper(String directoryName, List<File> files) {
- File directory = new File(directoryName);
- // Get all the files from a directory.
- File[] fList = directory.listFiles();
- if (fList == null)
- return;
- for (File file : fList) {
- if (file.isFile()) {
- files.add(file);
- } else if (file.isDirectory()) {
- getAllFilesHelper(file.getAbsolutePath(), files);
- }
- }
- }
- public static void main(String[] args) {
- System.out.println("Hello again!");
- // will print paths of all files in folder and subfolders
- System.out.println(getAllImages("C:\\temp"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement