HDFS:如何递归列出文件? [英] HDFS: How do you list files recursively?
问题描述
您如何通过Java在递归的HDFS中的某个路径下列出所有文件.我通过API并注意到FileSystem.listFiles(Path,boolean),但是在初始化它时,在我的FileSystem实例中似乎不存在该方法.
How do you, through Java, list all files (recursively) under a certain path in HDFS. I went through the API and noticed FileSystem.listFiles(Path,boolean) but it looks like that method doesn't exist in my instance of FileSystem when I initialize it.
推荐答案
您可以查看您的hadoop版本的org.apache.hadoop.fs.FsShell.ls(FileStatus, FileSystem, boolean, boolean)
源-这是从命令行执行hadoop fs -lsr path
时所调用的
You can look at the source for org.apache.hadoop.fs.FsShell.ls(FileStatus, FileSystem, boolean, boolean)
for your version of hadoop - this is what is called when you perform a hadoop fs -lsr path
from the command line
- 1.0.2 -第590行
- 0.20.2 - line 593
- 1.0.2 - line 590
这篇关于HDFS:如何递归列出文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!