这关直接写代码不用干其他的事

代码有点长,不好截图,你们别直接复制哦,自己动手敲一遍

敲完之后,点击提交验证结果

    //请在 Begin-End 之间添加代码,完成本关任务。
        /********* Begin *********/

        // HDFS文件系统地址
        String uri = "hdfs://localhost:9000/";
        // 需要删除的目录
    String d_path1 = "hdfs://localhost:9000/user/hadoop";
        // 重新创建user目录
        String c_path1 = "hdfs://localhost:9000/user";
        // 配置
        Configuration config = new Configuration();
        // 创建FileSystem对象
        FileSystem fs = FileSystem.get(URI.create(uri),config);
        // 需要删除的牡蛎
        fs.delete(new Path(d_path1),true);
        // 将目录输出
        Path[] paths = {new Path(uri),new Path(c_path1)};
        FileStatus[] status = fs.listStatus(paths);
        Path[] listPaths = FileUtil.stat2Paths(status);
        for(Path path : listPaths) { 
            System.out.println(path);
        }
    /********* End *********/
最后修改:2021 年 07 月 14 日
如果觉得我的文章对你有用,请随意赞赏