Java Directory to File List getAllFiles(File dir, List fileList)

Here you can find the source of getAllFiles(File dir, List fileList)

Description

get All Files

License

Open Source License

Declaration

public static boolean getAllFiles(File dir, List<File> fileList) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

import java.io.IOException;

import java.util.List;

public class Main {
    public static boolean getAllFiles(File dir, List<File> fileList) {
        try {//from ww  w .ja va2s.c o m
            File[] files = dir.listFiles();
            for (File file : files) {
                fileList.add(file);
                if (file.isDirectory()) {
                    System.out.println("directory:" + file.getCanonicalPath());
                    getAllFiles(file, fileList);
                } else {
                    System.out.println("     file:" + file.getCanonicalPath());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        }

        return true;
    }
}

Related

  1. getAllFileNamesInDir(String folderName)
  2. getAllFileNamesWithExtension(String directory, final String extension)
  3. getAllFilePath(String filedir)
  4. getAllFiles(File dir)
  5. getAllFiles(File dir)
  6. getAllFiles(File dir, List fileList)
  7. getAllFiles(File dir, Pattern filter)
  8. getAllFiles(File directory)
  9. getAllFiles(File directory)