File count in an HDFS directory

前端 未结 6 1993
攒了一身酷
攒了一身酷 2021-01-31 10:36

In Java code, I want to connect to a directory in HDFS, learn the number of files in that directory, get their names and want to read them. I can already read the files but I co

6条回答
  •  清歌不尽
    2021-01-31 11:03

    FileSystem fs = FileSystem.get(conf);
    Path pt = new Path("/path");
    ContentSummary cs = fs.getContentSummary(pt);
    long fileCount = cs.getFileCount();
    

提交回复
热议问题