I need to skip recording, if I get any exception, iterating the contents of the file using Java 8 and Spark.
I don’t want to throw an exception, I just need to skip this entry and continue with other entries.
Code example:
JavaRDD<Model> fileRDD = sc.textFile("filePath")
.map(line -> {
try {
String[] parts = line.split("\\|");
Long key = Long.parseLong(parts[0];
return line;
} catch (NumberFormatException nfe) {
}
});
source
share