object WordCount { def main(args : Array[String]): Unit = { val conf = new SparkConf().setAppName("wordCount").setMaster("local[*]") val sc = new SparkContext(conf) val line = sc.textFile("/Users/lifei/Desktop/ab/a.txt");//todo wholeTextFiles 可以读取目录 // 直接打印 // line.flatMap(_.split(" ")).map((_,1)).reduceByKey(_+_).collect().foreach(println)