解决MapReduce输出路径已存在的问题

当我们写好一个MapReduce函数时,由于测试,经常需要手动将之前的输出路径删除掉,不然的话,就会报以下的错误:

这个时候,我们只需要在我们的Driver端代码里面添加以下几行代码即可:

 FileSystem fileSystem = FileSystem.get(configuration);
        Path outputPath = new Path("output/d=20180717");
        if(fileSystem.exists(outputPath)){
            fileSystem.delete(outputPath,true);
        }

猜你喜欢

转载自blog.csdn.net/qq_34341930/article/details/88779322
今日推荐