Groovy_遍历文件目录
来源:互联网 发布:手机照片分类软件 编辑:程序博客网 时间:2024/04/28 01:37
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 files.
class eachDirTest { public static void main(String[] args) { def count = 0 def dir = new File("D:\\Project\\SoapUI\\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\\SoapUI\\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 } } }
- Groovy_遍历文件目录
- Groovy_遍历文件
- JSP遍历文件目录
- 遍历文件目录
- CFileFind 遍历文件目录
- 递归遍历目录文件
- 遍历文件目录
- 遍历目录得到文件
- 遍历目录所有文件
- 遍历目录查找文件
- 遍历文件和目录
- C#遍历文件目录
- air 遍历目录 文件
- VB遍历目录文件
- 递归遍历目录文件
- python 文件目录遍历
- opencv 目录文件遍历
- 遍历文件目录
- 猴子选大王
- RasPBX/FreePBX/Asterisk简单应用
- 从两句汇编认识运行时地址与链接地址
- 前端js和后台配合构建树的方式
- PHP抽奖程序概率算法
- Groovy_遍历文件目录
- java方法重载
- 连一粝的博客 VS2005更改解决方案及工程的名称
- 初识React
- 常用正则表达式
- 移动端开发者福利-免费收费api收藏
- Java - CompareDateTime、CompareDate、CompareTime、SameDateTime、SameDate、SameTime - 对比时间的函数
- 统计字符串中各个字符出现的次数
- android活动之间的通信 setResult两种不同回调方法的差异