Spark Scala list folders in directory

We are using hadoop 1.4 and it doesn’t have listFiles method so we use listStatus to get directories. It doesn’t have recursive option but it is easy to manage recursive lookup.

val fs = FileSystem.get(new Configuration())
val status = fs.listStatus(new Path(YOUR_HDFS_PATH))
status.foreach(x=> println(x.getPath))

Leave a Comment