HDFS:如何递归列出文件? [英] HDFS: How do you list files recursively?

查看:299
本文介绍了HDFS:如何递归列出文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您如何通过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

  • 0.20.2 - line 593
  • 1.0.2 - line 590

这篇关于HDFS:如何递归列出文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆