码迷,mamicode.com
首页 > 其他好文 > 详细

从代码上解决Output directory already exists错误,避免每次调试都要手动删除输出文件夹

时间:2017-11-05 22:22:59      阅读:276      评论:0      收藏:0      [点我收藏+]

标签:new   color   path   sys   bsp   class   dem   directory   tin   

// 判断output文件夹是否存在,如果存在则删除
    Path outPath = new Path("hdfs://192.168.9.13:8020/meanwhileFind");// 输出路径
    FileSystem fs = outPath.getFileSystem(conf);// 根据输出路径找到文件,参数为配置文件
    if (fs.exists(outPath)) {
        fs.delete(outPath);
        // fs.delete(outPath, true);true的意思是,就算output有东西,也一带删除,默认为true

    }
    FileInputFormat.setInputPaths(job, new Path("hdfs://192.168.9.13:8020/gradeMarking"));
    FileOutputFormat.setOutputPath(job, outPath);

 

从代码上解决Output directory already exists错误,避免每次调试都要手动删除输出文件夹

标签:new   color   path   sys   bsp   class   dem   directory   tin   

原文地址:http://www.cnblogs.com/le-ping/p/7788947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!