probably my question is rather obvious. Would like to look on the one directory and createthe the List of the String, where each string represents the file name stored in given direcotry, e.g. List("file1.csv", "file2.csv", "file3.csv").
I use the function which creates list, but it's list of Files (not Strings) and includes full paths (not only the file names).
import java.io.File
def getFileNames(path: String): List[File] = {
val d = new File(path)
if (d.exists && d.isDirectory) {
d
.listFiles // create list of File
.filter(_.isFile)
.toList
.sortBy(_.getAbsolutePath().replaceAll("[^a-zA-Z0-9]",""))
} else {
Nil // return empty list
}
}
Thank you for all the ideas.