【发布时间】:2016-11-06 15:24:15
【问题描述】:
我需要在 scala 中创建目录到文件的 HashMap,同时列出目录中的所有文件。我怎样才能在scala中实现这一点?
val directoryToFile = awsClient.listFiles(uploadPath).collect {
case path if !path.endsWith("/") => {
path match {
// do some regex matching to get directory & file names
case regex(dir, date) => {
// NEED TO CREATE A HASH MAP OF dir -> date. How???
}
case _ => None
}
}
}
listFiles(path: String) 方法返回作为参数传递给函数的path 中所有文件的绝对路径Seq[String]
【问题讨论】:
-
listFiles返回什么? -
@YuvalItzchakov Seq[String] 这是目录中所有文件的绝对路径列表
标签: java scala scala-collections