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.File;

import java.util.ArrayList;
import java.util.List;

public class Main {

    public static List<String> getAllFileName(String path) {
        File file = new File(path);
        File[] fileName = file.listFiles();
        List<String> list = new ArrayList<>();
        if (file.isDirectory()) {
            for (File string : fileName)
                if (new File(string.getPath()).isFile()) {
                    System.out.println(string.getPath());
                    list.add(string.getPath());
                }//from w ww .  ja  v  a  2s  .  c  o  m
        } else {
            System.out.println("it's a file.");
            //System.exit(1);
        }
        return list;
    }
}

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)