I have solved the problems from the Java book, and I have some questions.
In the code below, I want to create a new stream by doubling each element using the map intermediate operation. And I want to print a new stream to get the sum of all the elements except the number less than 50 in the generated stream.
How can i solve this ??
package test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.stream.Stream;
import java.util.Optional;
import java.util.stream.IntStream;
public class tt {
public static void main(String[] args) {
try {
Stream <String> lines = Files.lines(Paths.get("C:\\Users\\wonheelee\\eclipse-workspace\\test\\stream-data.txt"));
IntStream IS = lines.mapToInt(Integer::valueOf);
IS.forEach(System.out::println);
lines.close();
} catch (IOException e) {
// No action
}
}
}