1-groupBy
Map<String, List<User>> map = list.parallelStream() .collect(Collectors.groupingBy(User::getClass));
Map<Integer, Long> map = list.parallelStream() .collect(Collectors.groupingBy(User::getId, Collectors.counting()));
2- toList
List<Long> ids = list.stream().map(User::getId).collect(Collectors.toList());
3-sum
int sum = list.stream() .mapToInt(u -> u.getScore()).sum();
4-filter
List<User> list = list.stream().filter(u -> u.getScore()>60).collect(Collectors.toList());
5-findAny
boolean has100= list.stream().filter(u -> u.getScore()==60).findAny().isPresent();
6-findAny
Map<Integer, User> userMap = users.stream() .collect(Collectors.toMap(User::getType, Function.identity()));
7-GroupBy
Map<Integer, List<Detail> resultMap = details.stream() .collect(Collectors.groupingBy( detail -> detail.getType(), Collectors.toList()));
8-GroupBy & Sum
Map<Integer, BigDecimal> resultMap = details.stream() .collect(Collectors.groupingBy( detail -> detail.getType(), Collectors.mapping(detail -> detail.getAmount(), Collectors.reducing(BigDecimal.ZERO, BigDecimal::add)) ));
其他
StreamUtils.copyToString(request.getInputStream(), Charset.forName("UTF-8"))