Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下工作,但我想为包含添加一个条件列表。我似乎无法发挥作用。
val Files = dir .listFiles .filter(_.getName.contains("INIT")) .sorted .map(f => f.toString)
我想以最有效的方式检查 INIT 和 UPD 和 DEL。我尝试过的所有选项都没有产生结果。
您想检查给定子字符串列表中是否存在子字符串,以便文件名包含子字符串。在代码中:
val substrings = List("INIT", "UPD", "DEL") dir .listFiles .filter(f => { val n = f.getName substrings.exists(n.contains) }) .sorted .map(f => f.toString)