Code For Deleting Output Folder If Exist In Hadoop MapReduce Jobs

Mostly Hadoop MapReduce Jobs operates with two arguments.
Input directory and Output directory.

Each time when we run our MapReduce job we need to give non-existing folder as our output path. So while we are doing a Trail and Error method in our MR jobs. It is good if it automatically deletes the output folder if exists.

Here is the code for that:
/*Provides access to configuration parameters*/

Configuration conf = new Configuration();

FileSystem fs = FileSystem.get(conf);

if(fs.exists(new Path(args[1])))

{

fs.delete(new Path(args[1]),true);

}

Naveen P.N

12+ years of experience in IT with vast experience in executing complex projects using Java, Micro Services , Big Data and Cloud Platforms. I found NPN Training Pvt Ltd a India based startup to provide high quality training for IT professionals. I have trained more than 3000+ IT professionals and helped them to succeed in their career in different technologies. I am very passionate about Technology and Training. I have spent 12 years at Siemens, Yahoo, Amazon and Cisco, developing and managing technology.