Created
March 12, 2023 07:26
-
-
Save programsimon/8dab86c591800947584af21825084275 to your computer and use it in GitHub Desktop.
[Java Stream 流使用] #stream
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void stream(){ | |
| List<String> myList = | |
| Arrays.asList("a1", "a2", "b1", "c2", "c1"); | |
| //查找第一个符合条件的 | |
| myList | |
| .stream() | |
| .filter(x -> x.getClass().equals(StringHttpMessageConverter.class)) | |
| .findFirst() | |
| .orElse(null); | |
| //根据条件过滤,获取所有符合条件的元素集合 | |
| Arrays.stream(clazz.getMethods()) | |
| .filter(m -> m.getName().equalsIgnoreCase(methodName)) | |
| .filter(m -> Modifier.isPublic(m.getModifiers())) | |
| .collect(Collectors.toList()); | |
| //遍历每个元素 | |
| cachedWorkbook.values() | |
| .forEach(w -> FileUtils.deleteFile(w.cachedFileName)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment