单机版本:
package com.itheima.java_wordcount;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.FlatMapFunction;
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairFunction;
import scala.Tuple2;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* Date:2019/4/24
* Author:Lynn.cn.Li
* Desc:
*/
public class WordCountJava {
public static void main(String[] args) {
// 1.创建sparkConf对象。设置appName和master地址
SparkConf sparkConf = new SparkConf().setAppName("LocalJavaWordCount").setMaster("local[2]");
// 2.创建sparkContext对象
JavaSparkContext jsc = new JavaSparkContext(sparkConf);
// 3.读取数据文件
JavaRDD<String> textFileR