1、背景
为了分析HDFS文件生命周期,需要获取一定深度的HDFS目录。
2、实现
static final String hdfsBaseDir = "hdfs://nameservice1:8020";
static final int depth = 6;
static FileSystem fs = null;
static BufferedWriter out = null;
static int cacheNum = 0;
static int cnt = 0;
private static void listAllFiles(Path path) throws Exception {
// 根据path.toString 可以过滤一些不需要扫描的目录
FileStatus[] array = fs.listStatus(path);
Path[] paths = FileUtil.stat2Paths(array);