Anonymous user
Walk a directory/Recursively: Difference between revisions
→{{header|Groovy}}: Added more Groovy variants
(→{{header|Haskell}}: Add link to directory package) |
(→{{header|Groovy}}: Added more Groovy variants) |
||
Line 877:
=={{header|Groovy}}==
<lang groovy>new File('.').eachFileRecurse {
if (it.name =~ /.*\.txt/) println it;
}</lang>
Shorter variant:
<lang groovy>new File('.').eachFileRecurse ~/.*\.txt/, { println it }</lang>
Variant processing only files:
<lang groovy>new File('.').eachFileRecurse FILES, ~/.*\.txt/, { println it }</lang>
Flexible search, traversal can be adapted by providing various options in the options Map, see documentation of method:
[http://docs.groovy-lang.org/latest/html/groovy-jdk/java/io/File.html#traverse(java.util.Map,%20groovy.lang.Closure) traverse(Map options, Closure closure)]
<lang groovy>new File('.').traverse(
type : FILES,
nameFilter : ~/.*\.txt/,
preDir : { if (it.name == '.svn') return SKIP_SUBTREE },
) { println it }
</lang>
=={{header|GUISS}}==
|