import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
object WordCount {
def main(args: Array[String]) {
val conf = new SparkConf()
conf.setAppName("WordCount")
val sc = new SparkContext(conf)
val file = "hdfs://127.0.0.1:9000/file.txt"
val lines = sc.textFile(file)
val words = lines.flatMap(_.split("\\s+"))
val wordCount = words.countByValue() println(wordCount)
}
}