Java Folder Read getFiles(String dir)

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

Description

get Files

License

Apache License

Declaration

public static List<String> getFiles(String dir) 

Method Source Code


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

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

public class Main {
    public static List<String> getFiles(String dir) {
        List<String> files = new ArrayList<>();
        File folder = new File(dir);
        File[] listOfFiles = folder.listFiles();

        for (int i = 0; i < listOfFiles.length; i++) {
            if (listOfFiles[i].isFile()) {
                files.add(listOfFiles[i].getAbsolutePath());
            } else if (listOfFiles[i].isDirectory()) {
                System.out.println("Directory " + listOfFiles[i].getName());
            }// w  w w. j a  v  a  2s .  c o  m
        }
        return files;
    }
}

Related

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