Stream + Lambda 用来处理、转换数据确实非常合适。
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class Test {
public static void main(String[] args) {
String str = "1, 22, 7, 20, 101, 30";
List numbers = Arrays.stream(str.split(","))
.map(s -> Long.valueOf(s.trim()))
.filter(t -> t < 100)
.sorted()
.collect(Collectors.toList());
System.out.println(numbers);
// [1, 7, 20, 22, 30]
}
}
Maven, 参考 reactor-by-example
io.projectreactor
reactor-core
3.4.22