工作前自动删除已有文件
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.fjy.hadoop.mapreduce;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.io.LongWritable;
|
||||
import org.apache.hadoop.io.Text;
|
||||
@@ -87,6 +88,14 @@ public class WordCountApp {
|
||||
//创建Configuration
|
||||
Configuration configuration = new Configuration();
|
||||
|
||||
//清理已存在的输出目录
|
||||
Path outputPath = new Path(args[1]);
|
||||
FileSystem fileSystem = FileSystem.get(configuration);
|
||||
if (fileSystem.exists(outputPath)){
|
||||
fileSystem.delete(outputPath);
|
||||
System.out.println("The exist files had been deleted!");
|
||||
}
|
||||
|
||||
//创建作业
|
||||
Job job = Job.getInstance(configuration, "wordcount");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user