objectWordCount{ defmain(args: Array[String]) { val inputFile = "file:///E://test.txt" val conf = newSparkConf().setAppName("WordCount").setMaster("local") val sc = newSparkContext(conf) val textFile = sc.textFile(inputFile) val wordCount = textFile.flatMap(line => line.split(" ")).map(word => (word, 1)).reduceByKey((a, b) => a + b) wordCount.foreach(println) } }