hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raimon Bosch <raimon.bo...@gmail.com>
Subject How to iterate over a hdfs folder with hadoop
Date Mon, 10 Oct 2011 15:03:05 GMT
Hi,

I'm wondering how can I browse an hdfs folder using the classes
in org.apache.hadoop.fs package. The operation that I'm looking for is
'hadoop dfs -ls'

The standard file system equivalent would be:

File f = new File(outputPath);
if(f.isDirectory()){
  String files[] = f.list();
  for(String file : files){
    //Do your logic
  }
}

Thanks in advance,
Raimon Bosch.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message