Below is the code where I try to process lines read by from the file in parallel stream and in Normal stream. Surprisingly, parallel stream gives no improvements over normal stream . Am I missing something here ?
Files.walk(Paths.get(tweetFilePath + LocalDate.now())).forEach(
filePath -> {
if (Files.isRegularFile(filePath) && !filePath.toString().endsWith(".DS_Store")) {
long startTime = System.currentTimeMillis();
try {
Files.lines(filePath).parallel().forEach(line -> {
try {
System.out.println(line);
} catch (Exception e) {
System.out.println("Not able to crunch"+ e);
}
});
} catch (Exception e) {
System.out.println("Bad line in file ");
}finally {
System.out.println("total time required:" + (System.currentTimeMillis() - startTime));
}
}
});