Here you can find the source of getAllFiles(String dirPath)
Parameter | Description |
---|---|
dirPath | a parameter |
public static List<String> getAllFiles(String dirPath)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.util.ArrayList; import java.util.List; public class Main { /**// ww w . j a v a2 s. co m * Get list of files path under the directory recursively * @param dirPath * @return */ public static List<String> getAllFiles(String dirPath) { List<String> files = new ArrayList<>(); File folder = new File(dirPath); File[] listOfFiles = folder.listFiles(); for (int i = 0; i < listOfFiles.length; i++) { File file = listOfFiles[i]; String filePath = file.getPath(); if (file.isFile()) { if (!file.isHidden() && !file.getName().startsWith("_")) files.add(filePath); } else if (file.isDirectory()) { files.addAll(getAllFiles(filePath)); } } return files; } }