object WordCount { def main(args: Array[String]) { // val inputFile = "file:///home/mi/coding/coding/Scala/word-count/input/README.txt" // val inputFile = "file://README.txt" val inputFile = "/user/XXXX/lintong/README.txt" val conf = new SparkConf().setAppName("WordCount").setMaster("yarn-client") val sc = new SparkContext(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) // wordCount.saveAsTextFile("file:///home/mi/coding/coding/Scala/word-count/output/READMEOUT.txt") wordCount.saveAsTextFile("/user/XXXX/lintong/READMEOUT.txt") } }