def getFile(file:File): Array[File] ={
val files = file.listFiles().filter(! _.isDirectory)
    .filter(t => t.toString.endsWith(".txt") || t.toString.endsWith(".md"))  //此处读取.txt and .md文件
    files ++ file.listFiles().filter(_.isDirectory).flatMap(getFile)
}

val path = new File("G:\\lzp_personal_data\\study_data\\itNote")
getFile(path).foreach(println)

相关文章:

  • 2021-09-10
  • 2021-11-18
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
相关资源
相似解决方案