无法找出列出目录和子目录中所有文件的方法。
这是我正在使用的代码,它列出了特定目录中的文件,但如果内部有子目录则列出文件:
val conf = new Configuration()
val fs = FileSystem.get(new java.net.URI("hdfs://servername/"), conf)
val status = fs.listStatus(new Path("path/to/folder/"))
status.foreach { x => println(x.getPath.toString()) }
Run Code Online (Sandbox Code Playgroud)
上面的代码列出了目录中的所有文件,但我需要它是递归的。