@@ -0,0 +1,995 @@
+/**%0A * Illustrates a simple flatMap in Java to extract the words%0A */%0Apackage com.oreilly.learningsparkexamples.java;%0A%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.apache.commons.lang.StringUtils;%0A%0Aimport org.apache.spark.api.java.JavaRDD;%0Aimport org.apache.spark.api.java.JavaSparkContext;%0Aimport org.apache.spark.api.java.function.FlatMapFunction;%0A%0Apublic class BasicFlatMap %7B%0A  public static void main(String%5B%5D args) throws Exception %7B%0A%0A%09%09if (args.length != 2) %7B%0A      throw new Exception(%22Usage BasicFlatMap sparkMaster inputFile%22);%0A%09%09%7D%0A%0A    JavaSparkContext sc = new JavaSparkContext(%0A      args%5B0%5D, %22basicflatmap%22, System.getenv(%22SPARK_HOME%22), System.getenv(%22JARS%22));%0A    JavaRDD%3CString%3E rdd = sc.textFile(args%5B1%5D);%0A    JavaRDD%3CString%3E result = rdd.flatMap(%0A      new FlatMapFunction%3CString, String%3E() %7B public Iterable%3CString%3E call(String x) %7B%0A          return Arrays.asList(x.split(%22 %22));%0A        %7D%7D);%0A    System.out.println(StringUtils.join(result.collect(), %22,%22));%0A  %7D%0A%7D%0A

Add wordcount example