Java Directory to File List GetAllFileName(String path)

Here you can find the source of GetAllFileName(String path)

Description

Get All File Name

License

Apache License

Declaration

public static List<String> GetAllFileName(String path) 

Method Source Code


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

import java.io.*;

import java.util.*;

public class Main {

    public static List<String> GetAllFileName(String path) {
        List<String> arrList = new ArrayList<String>();
        File file = new File(path);
        if (!file.exists()) {
            return arrList;
        }//from   ww  w . j  a  v  a  2s.  co  m
        if (!file.isDirectory()) {
            return arrList;
        }
        String[] tempList = file.list();
        File temp;
        for (String aTempList : tempList) {
            if (path.endsWith(File.separator)) {
                temp = new File(path + aTempList);
            } else {
                temp = new File(path + File.separator + aTempList);
            }
            if (temp.isFile()) {
                arrList.add(temp.getName());
            }
        }
        return arrList;
    }
}

Related

  1. getAllFile(File directory, boolean descendIntoSubDirectories, String endofFile, String hiddenFileSuffix)
  2. getAllFile(List list, File rootFile)
  3. getAllFile2(String Url)
  4. getAllFileFromPath(File file, List fileList, String ed)
  5. getAllFileName(String path)
  6. getAllFileName(String path, ArrayList fileName)
  7. getAllFileNames(File basedir, String path)
  8. getAllFileNames(String path, String suffix, boolean isDepth)
  9. getAllFileNamesByPath(String path)