How do I get the list of files (or all *.txt files for example) in a directory in Scala. The Source class does not seem to help.
|
|
|||
|
The Java File class is really all you need, although it's easy enough to add some Scala goodness to iteration over directories easier.
|
|||||
|
The JDK7 version, using the new DirectoryStream class is:
Instead of a string, this returns a Path, which has loads of handy methods on it, like 'relativize' and 'subpath'. Note that you will also need to import |
|||||||||||||||||
|
For now, you should use Java libraries to do so. |
|||
|