[prev in list] [next in list] [prev in thread] [next in thread]
List: groovy-user
Subject: [groovy-user] Simple Groovy script for dumping directory structure
From: bgoetzmann <bgoetzmann () sophia ! symag ! com>
Date: 2009-03-31 16:20:45
Message-ID: 22805221.post () talk ! nabble ! com
[Download RAW message or body]
If it can help someone, here a simple Groovy script for dumping a directory
structure:
def depth = 0
def dump // necessary for Closure recursivity
dump = {
it.listFiles().each { file ->
println '....' * depth + file.name
if (file.isDirectory()) {
depth++
dump(file)
depth--
}
}
}
dump(new File('D:/groovy-1.6.0'))
Applied to my Groovy directory, this script displays something like:
ANTLR-LICENSE.txt
ASM-LICENSE.txt
bin
....grape
....grape.bat
....groovy
....groovy.bat
....groovyc
....groovyc.bat
....groovyConsole
....groovyConsole.bat
....groovysh
....groovysh.bat
....java2groovy
....java2groovy.bat
....startGroovy
....startGroovy.bat
CLI-LICENSE.txt
conf
....groovy-starter.conf
embeddable
....groovy-all-1.6.0.jar
...
If there is a more Groovy way to do a such thing, I'll take it ;-)
Cheers,
Bertrand.
http://www.odelia-technologies.com
http://www.grailsworks.com
--
View this message in context: \
http://www.nabble.com/Simple-Groovy-script-for-dumping-directory-structure-tp22805221p22805221.html
Sent from the groovy - user mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic