job.setOutputKeyClass(Text.class);
FileInputFormat.setInputPaths(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.out.println(job.waitForCompletion(true) ? “运行成功” : “运行失败”);
}
public static void main(String[] args) {
try {
WordCountMain wordCountMain = new WordCountMain(args);
} catch (Exception e) {
e.printStackTrace();
}
}
}
map类:
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class MyMapper extends Mapper<LongWritable, Text, Text, LongWritable> {
@Override
protected void map(LongWritable key, Text value, Context context) {
String line = value.toString();
String[] words = line.split(" ");
for (String word : words) {<