I need to skip the record, if i get any exception while iterating the file content using Java 8 and Spark.
I do not want to throw exception, i just need to skip that record and continue with other records.
Code Example is :
JavaRDD<Model> fileRDD = sc.textFile("filePath")
.map(line -> {
try {
String[] parts = line.split("\\|");
Long key = Long.parseLong(parts[0];
return line;
} catch (NumberFormatException nfe) {
//if i throw RuntimeException, its working file
//but i dont want to throw exception, i want to just skip the line,
// how do i do it using java 8 stream methods
}
});