Home »
Code Examples »
Groovy Code Examples
Groovy - Get a list of all the files in a directory (recursive) Code Example
The code for Get a list of all the files in a directory (recursive)
import groovy.io.FileType
def list = []
def dir = new File("path_to_parent_dir")
dir.eachFileRecurse (FileType.FILES) { file ->
list << file
}
//Afterwards the list variable contains all files (java.io.File) of
//the given directory and its subdirectories
list.each {
println it.path
}
Code by IncludeHelp,
on August 7, 2022 06:19
Reference:
stackoverflow