Is there a good \"scala-esque\" (I guess I mean functional) way of recursively listing files in a directory? What about matching a particular pattern?
For example re
I would prefer solution with Streams because you can iterate over infinite file system(Streams are lazy evaluated collections)
import scala.collection.JavaConversions._
def getFileTree(f: File): Stream[File] =
f #:: (if (f.isDirectory) f.listFiles().toStream.flatMap(getFileTree)
else Stream.empty)
Example for searching
getFileTree(new File("c:\\main_dir")).filter(_.getName.endsWith(".scala")).foreach(println)