Official Documentation: http://docs.groovy-lang.org/latest/html/groovy-jdk/java/io/File.html
Common Method:
1. Void Eachdir (Closure Closure): invokes the Closure for each subdirectory in this directory, ignoring regular F Iles.
Class Eachdirtest {public
static void Main (string[] args) {
def count = 0
def dir = new File ("D:\\project\\so Apui\\project-smoke-tests ")
dir.eachdir{directory->
println directory
}
}
2. Void Eachdirmatch (Object namefilter, Closure Closure): Invokes the Closure for each subdirectory whose name (Dir.name) matches the given namefilter in the given directory-calling the Defaultgroovymethods#iscase (Java.lang.Object, method to determine if a match occurs.
Class Eachdirtest {public
static void Main (string[] args) {
def count = 0
def dir = new File ("D:\\project\\so Apui\\project-smoke-tests ")
Dir.eachdirmatch (~/^sanity.*/) {D-
println D
}
}
}
Output:
D:\Project\SoapUI\Project-smoke-tests\SanityTestSuite1
D:\Project\SoapUI\Project-smoke-tests\SanityTestSuite2
D:\Project\SoapUI\Project-smoke-tests\SanityTestSuite3
D:\Project\SoapUI\Project-smoke-tests\SanityTestSuite4
D:\Project\SoapUI\Project-smoke-tests\SanityTestSuite5
........
3. Eachdirrecurse (File Self, Closure Closure): Invokes the Closure for each descendant directory of this directory.
class eachdirtest {public static void main (string[] args) {def count = 0
def dir = new File ("D:\\project\\soapui\\project-smoke-tests") dir.eachdirrecurse{directory-> println Directory}}}