Java Folder Read getFiles(String dir)

Here you can find the source of getFiles(String dir)

Description

get Files

License

Apache License

Declaration

private static List<String> getFiles(String dir) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Main {

    private static List<String> getFiles(String dir) {
        List<String> lstFiles = new ArrayList<>();
        File file = new File(dir);
        File[] files = file.listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.isDirectory()) {
                    lstFiles.add(f.getAbsolutePath());
                    lstFiles.addAll(getFiles(f.getAbsolutePath()));
                } else {
                    String str = f.getAbsolutePath();
                    lstFiles.add(str);//from   www.ja  v  a 2 s . c  o m
                }
            }
        }
        return lstFiles;
    }
}

Related

  1. getFiles(final String path, Vector files)
  2. getFiles(List filepaths)
  3. getFiles(List filePaths)
  4. getFiles(List l, String directory)
  5. getFiles(String _path)
  6. getFiles(String dir)
  7. getFiles(String dir)
  8. getFiles(String directoryPath)
  9. getFiles(String dirName, int number)