title: Removing nulls while mapping a JavaRDD
body: <p>I am developing a Java + Apache Spark application. One of its funcionalities is to trim Strings. For example:</p>
  
  <pre><code>// Having JavaSparkContext jsc previously defined and a function like 
  // the following already defined:
  private String trim(String s, int charsToTrim);
  // that returns a new String with length = s.length() - charsToTrim or 
  // null if its new length is &lt;= 0
  
  JavaRDD&lt;String&gt; original = jsc.parallelize(Arrays.asList("aaa", "bbbb", "ccccc");
  int num = 4;
  JavaRDD&lt;String&gt; mapped = original.map(s -&gt; trim(s, num));
  </code></pre>
  
  <p>The new JavaRDD mapped will contain (null, null, "c"), and I will have to clean null values with a filter. </p>
  
  <p>The question I have is: Is there any way to remove those values while doing the map or to don't return any value at while mapping all if the result is null? </p>
  
  <p>Thank you.</p>