0

I want to make a list of all the files present in a directory, using groovy.

What would a good code to do the task?

Thanks in Advance.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Yash
  • 11
  • 6

1 Answers1

1

Here is how you do that:

File[] files = new File("/some/path/you/are/interested/in").listFiles()
println( files )

That will include directories AND files. If you just want files then you can do this:

File[] files = new File("/some/path/you/are/interested/in").listFiles({ it.isFile() } as FileFilter)
println( files )
chubbsondubs
  • 37,646
  • 24
  • 106
  • 138