@@ -0,0 +1,1373 @@
+/**%0A * Illustrates a wordcount in Java%0A */%0Apackage com.oreilly.learningsparkexamples.java;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.lang.Iterable;%0A%0Aimport scala.Tuple2;%0A%0Aimport org.apache.commons.lang.StringUtils;%0A%0Aimport org.apache.spark.api.java.JavaRDD;%0Aimport org.apache.spark.api.java.JavaPairRDD;%0Aimport org.apache.spark.api.java.JavaSparkContext;%0Aimport org.apache.spark.api.java.function.FlatMapFunction;%0Aimport org.apache.spark.api.java.function.Function2;%0Aimport org.apache.spark.api.java.function.PairFunction;%0A%0A%0Apublic class WordCount %7B%0A  public static void main(String%5B%5D args) throws Exception %7B%0A%09%09String master = args%5B0%5D;%0A%09%09JavaSparkContext sc = new JavaSparkContext(%0A      master, %22wordcount%22, System.getenv(%22SPARK_HOME%22), System.getenv(%22JARS%22));%0A    JavaRDD%3CString%3E rdd = sc.textFile(args%5B1%5D);%0A    JavaPairRDD%3CString, Integer%3E counts = rdd.flatMap(%0A      new FlatMapFunction%3CString, String%3E() %7B%0A        public Iterable%3CString%3E call(String x) %7B%0A          return Arrays.asList(x.split(%22 %22));%0A        %7D%7D).map(new PairFunction%3CString, String, Integer%3E()%7B%0A            public Tuple2%3CString, Integer%3E call(String x)%7B%0A              return new Tuple2(x, 1);%0A            %7D%7D).reduceByKey(new Function2%3CInteger, Integer, Integer%3E()%7B%0A                public Integer call(Integer x, Integer y)%7B return x+y;%7D%7D);%0A    counts.saveAsTextFile(args%5B2%5D);%0A%09%7D%0A%7D%0A

Add wordcount java example