I have a directory "/local/dath/mi/" which is including many files
03_ssa_fruits.csv
03_ssa_can.csv
03_ssa_veg.csv
sxattru.csv
sxprod.csv
sxstore.csv
I need to extract the list of specific files from that directory :
/local/dath/mi/03_ssa_fruits.csv
/local/dath/mi/03_ssa_can.csv
/local/dath/mi/03_ssa_veg.csv
I have tried the below code ,but it is not working.What I am doing wrong .Can anyone help me
def getListOfFiles(dir: String , naming: String): List[String] = {
File(dir).toJava.listFiles.filter(_.isFile).toList.filter { file =>
file.getName.startsWith("03_ss*")
}.map(_.toString)
}
val listOfFile = getListOfFiles(parentDir, File(data.salFilePath).toJava.getName())
*in file.getName.startsWith("03_ss*")startsWithhas no support of regexp including wildcard so you need to specify just prefix03_ss