I am trying to parse a MultipartFile line by line, and also count the total number of lines as it goes. Here's the snippet:
var inputStream = file.getInputStream();
var stream = new BufferedReader(
new InputStreamReader(inputStream, StandardCharsets.UTF_8)
).lines();
var totalTargetCount = 0l;
stream.forEach(line -> {
processTheLine(line);
totalTargetCount++;
});
But this gives the error Variable used in lambda expression should be final or effectively final What should I do in this case?